Merge branch 'master' into merge

This commit is contained in:
Andy Friesen 2023-05-05 12:57:23 -07:00
commit cc96f86c08
2 changed files with 20 additions and 12 deletions

View file

@ -92,7 +92,7 @@ type DateTypeResult = {
declare os: { declare os: {
time: (time: DateTypeArg?) -> number, time: (time: DateTypeArg?) -> number,
date: (formatString: string?, time: number?) -> DateTypeResult | string, date: ((formatString: "*t" | "!*t", time: number?) -> DateTypeResult) & ((formatString: string?, time: number?) -> string),
difftime: (t2: DateTypeResult | number, t1: DateTypeResult | number) -> number, difftime: (t2: DateTypeResult | number, t1: DateTypeResult | number) -> number,
clock: () -> number, clock: () -> number,
} }

View file

@ -22,12 +22,12 @@ stat = varlist '=' explist |
'function' funcname funcbody | 'function' funcname funcbody |
'local' 'function' NAME funcbody | 'local' 'function' NAME funcbody |
'local' bindinglist ['=' explist] | 'local' bindinglist ['=' explist] |
['export'] 'type' NAME ['<' GenericTypeParameterList '>'] '=' Type ['export'] 'type' NAME ['<' GenericTypeListWithDefaults '>'] '=' Type
laststat = 'return' [explist] | 'break' | 'continue' laststat = 'return' [explist] | 'break' | 'continue'
funcname = NAME {'.' NAME} [':' NAME] funcname = NAME {'.' NAME} [':' NAME]
funcbody = ['<' GenericTypeParameterList '>'] '(' [parlist] ')' [':' ReturnType] block 'end' funcbody = ['<' GenericTypeList '>'] '(' [parlist] ')' [':' ReturnType] block 'end'
parlist = bindinglist [',' '...'] | '...' parlist = bindinglist [',' '...'] | '...'
explist = {exp ','} exp explist = {exp ','} exp
@ -63,17 +63,25 @@ SimpleType =
NAME ['.' NAME] [ '<' [TypeParams] '>' ] | NAME ['.' NAME] [ '<' [TypeParams] '>' ] |
'typeof' '(' exp ')' | 'typeof' '(' exp ')' |
TableType | TableType |
FunctionType FunctionType |
'(' Type ')'
SingletonType = STRING | 'true' | 'false' SingletonType = STRING | 'true' | 'false'
Type = UnionSuffix = {'?'} {'|' SimpleType {'?'}}
SimpleType ['?'] | IntersectionSuffix = {'&' SimpleType}
Type ['|' Type] | Type = SimpleType (UnionSuffix | IntersectionSuffix)
Type ['&' Type]
GenericTypePackParameter = NAME '...'
GenericTypeList = NAME [',' GenericTypeList] | GenericTypePackParameter {',' GenericTypePackParameter}
GenericTypePackParameterWithDefault = NAME '...' '=' (TypePack | VariadicTypePack | GenericTypePack)
GenericTypeListWithDefaults =
GenericTypeList {',' GenericTypePackParameterWithDefault} |
NAME {',' NAME} {',' NAME '=' Type} {',' GenericTypePackParameterWithDefault} |
NAME '=' Type {',' GenericTypePackParameterWithDefault} |
GenericTypePackParameterWithDefault {',' GenericTypePackParameterWithDefault}
GenericTypePackParameter = NAME '...' ['=' (TypePack | VariadicTypePack | GenericTypePack)]
GenericTypeParameterList = NAME ['=' Type] [',' GenericTypeParameterList] | GenericTypePackParameter {',' GenericTypePackParameter}
TypeList = Type [',' TypeList] | '...' Type TypeList = Type [',' TypeList] | '...' Type
TypeParams = (Type | TypePack | VariadicTypePack | GenericTypePack) [',' TypeParams] TypeParams = (Type | TypePack | VariadicTypePack | GenericTypePack) [',' TypeParams]
TypePack = '(' [TypeList] ')' TypePack = '(' [TypeList] ')'
@ -84,6 +92,6 @@ TableIndexer = '[' Type ']' ':' Type
TableProp = NAME ':' Type TableProp = NAME ':' Type
TablePropOrIndexer = TableProp | TableIndexer TablePropOrIndexer = TableProp | TableIndexer
PropList = TablePropOrIndexer {fieldsep TablePropOrIndexer} [fieldsep] PropList = TablePropOrIndexer {fieldsep TablePropOrIndexer} [fieldsep]
TableType = '{' PropList '}' TableType = '{' [PropList] '}'
FunctionType = ['<' GenericTypeParameterList '>'] '(' [TypeList] ')' '->' ReturnType FunctionType = ['<' GenericTypeList '>'] '(' [TypeList] ')' '->' ReturnType
``` ```