mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge branch 'master' into dynamicNames
This commit is contained in:
+25
-10
@@ -4210,13 +4210,13 @@ namespace ts {
|
||||
if (parentType === unknownType) {
|
||||
return unknownType;
|
||||
}
|
||||
// If no type was specified or inferred for parent, or if the specified or inferred type is any,
|
||||
// infer from the initializer of the binding element if one is present. Otherwise, go with the
|
||||
// undefined or any type of the parent.
|
||||
if (!parentType || isTypeAny(parentType)) {
|
||||
if (declaration.initializer) {
|
||||
return checkDeclarationInitializer(declaration);
|
||||
}
|
||||
// If no type was specified or inferred for parent,
|
||||
// infer from the initializer of the binding element if one is present.
|
||||
// Otherwise, go with the undefined type of the parent.
|
||||
if (!parentType) {
|
||||
return declaration.initializer ? checkDeclarationInitializer(declaration) : parentType;
|
||||
}
|
||||
if (isTypeAny(parentType)) {
|
||||
return parentType;
|
||||
}
|
||||
|
||||
@@ -4242,9 +4242,6 @@ namespace ts {
|
||||
// computed properties with non-literal names are treated as 'any'
|
||||
return anyType;
|
||||
}
|
||||
if (declaration.initializer) {
|
||||
getContextualType(declaration.initializer);
|
||||
}
|
||||
|
||||
// Use type of the specified property, or otherwise, for a numeric name, the type of the numeric index signature,
|
||||
// or otherwise the type of the string index signature.
|
||||
@@ -16921,6 +16918,12 @@ namespace ts {
|
||||
return resolveUntypedCall(node);
|
||||
}
|
||||
|
||||
if (isPotentiallyUncalledDecorator(node, callSignatures)) {
|
||||
const nodeStr = getTextOfNode(node.expression, /*includeTrivia*/ false);
|
||||
error(node, Diagnostics._0_accepts_too_few_arguments_to_be_used_as_a_decorator_here_Did_you_mean_to_call_it_first_and_write_0, nodeStr);
|
||||
return resolveErrorCall(node);
|
||||
}
|
||||
|
||||
const headMessage = getDiagnosticHeadMessageForDecoratorResolution(node);
|
||||
if (!callSignatures.length) {
|
||||
let errorInfo: DiagnosticMessageChain;
|
||||
@@ -16933,6 +16936,18 @@ namespace ts {
|
||||
return resolveCall(node, callSignatures, candidatesOutArray, headMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sometimes, we have a decorator that could accept zero arguments,
|
||||
* but is receiving too many arguments as part of the decorator invocation.
|
||||
* In those cases, a user may have meant to *call* the expression before using it as a decorator.
|
||||
*/
|
||||
function isPotentiallyUncalledDecorator(decorator: Decorator, signatures: Signature[]) {
|
||||
return signatures.length && every(signatures, signature =>
|
||||
signature.minArgumentCount === 0 &&
|
||||
!signature.hasRestParameter &&
|
||||
signature.parameters.length < getEffectiveArgumentCount(decorator, /*args*/ undefined, signature));
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is similar to getResolvedSignature but is exclusively for trying to resolve JSX stateless-function component.
|
||||
* The main reason we have to use this function instead of getResolvedSignature because, the caller of this function will already check the type of openingLikeElement's tagName
|
||||
|
||||
@@ -907,50 +907,54 @@
|
||||
"category": "Error",
|
||||
"code": 1328
|
||||
},
|
||||
"'unique symbol' types are not allowed in a union type.": {
|
||||
"'{0}' accepts too few arguments to be used as a decorator here. Did you mean to call it first and write '@{0}()'?": {
|
||||
"category": "Error",
|
||||
"code": 1329
|
||||
},
|
||||
"'unique symbol' types are not allowed in an intersection type.": {
|
||||
"'unique symbol' types are not allowed in a union type.": {
|
||||
"category": "Error",
|
||||
"code": 1330
|
||||
},
|
||||
"'unique symbol' types are not allowed in an array type.": {
|
||||
"'unique symbol' types are not allowed in an intersection type.": {
|
||||
"category": "Error",
|
||||
"code": 1331
|
||||
},
|
||||
"'unique symbol' types are not allowed in a tuple type.": {
|
||||
"'unique symbol' types are not allowed in an array type.": {
|
||||
"category": "Error",
|
||||
"code": 1332
|
||||
},
|
||||
"'unique symbol' types are not allowed in a mapped type.": {
|
||||
"'unique symbol' types are not allowed in a tuple type.": {
|
||||
"category": "Error",
|
||||
"code": 1333
|
||||
},
|
||||
"A property of an interface or type literal whose type is a 'unique symbol' type must be 'readonly'.": {
|
||||
"'unique symbol' types are not allowed in a mapped type.": {
|
||||
"category": "Error",
|
||||
"code": 1334
|
||||
},
|
||||
"A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'.": {
|
||||
"A property of an interface or type literal whose type is a 'unique symbol' type must be 'readonly'.": {
|
||||
"category": "Error",
|
||||
"code": 1335
|
||||
},
|
||||
"A variable whose type is a 'unique symbol' type must be 'const'.": {
|
||||
"A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'.": {
|
||||
"category": "Error",
|
||||
"code": 1336
|
||||
},
|
||||
"'unique symbol' types may not be used on a variable declaration with a binding name.": {
|
||||
"A variable whose type is a 'unique symbol' type must be 'const'.": {
|
||||
"category": "Error",
|
||||
"code": 1337
|
||||
},
|
||||
"'unique symbol' types are only allowed on variables in a variable statement.": {
|
||||
"'unique symbol' types may not be used on a variable declaration with a binding name.": {
|
||||
"category": "Error",
|
||||
"code": 1338
|
||||
},
|
||||
"'unique symbol' types are not allowed here.": {
|
||||
"'unique symbol' types are only allowed on variables in a variable statement.": {
|
||||
"category": "Error",
|
||||
"code": 1339
|
||||
},
|
||||
"'unique symbol' types are not allowed here.": {
|
||||
"category": "Error",
|
||||
"code": 1340
|
||||
},
|
||||
|
||||
"Duplicate identifier '{0}'.": {
|
||||
"category": "Error",
|
||||
|
||||
Executable → Regular
@@ -1,10 +1,34 @@
|
||||
/// <reference path="../harness.ts" />
|
||||
|
||||
describe("Public APIs", () => {
|
||||
it("for the language service and compiler should be acknowledged when they change", () => {
|
||||
Harness.Baseline.runBaseline("api/typescript.d.ts", () => Harness.IO.readFile("built/local/typescript.d.ts"));
|
||||
function verifyApi(fileName: string) {
|
||||
const builtFile = `built/local/${fileName}`;
|
||||
const api = `api/${fileName}`;
|
||||
let fileContent: string;
|
||||
before(() => {
|
||||
fileContent = Harness.IO.readFile(builtFile);
|
||||
});
|
||||
|
||||
it("should be acknowledged when they change", () => {
|
||||
Harness.Baseline.runBaseline(api, () => fileContent);
|
||||
});
|
||||
|
||||
it("should compile", () => {
|
||||
const testFile: Harness.Compiler.TestFile = {
|
||||
unitName: builtFile,
|
||||
content: fileContent
|
||||
};
|
||||
const inputFiles = [testFile];
|
||||
const output = Harness.Compiler.compileFiles(inputFiles, [], /*harnessSettings*/ undefined, /*options*/ {}, /*currentDirectory*/ undefined);
|
||||
assert(!output.result.errors || !output.result.errors.length, Harness.Compiler.minimalDiagnosticsToString(output.result.errors, /*pretty*/ true));
|
||||
});
|
||||
}
|
||||
|
||||
describe("for the language service and compiler", () => {
|
||||
verifyApi("typescript.d.ts");
|
||||
});
|
||||
it("for the language server should be acknowledged when they change", () => {
|
||||
Harness.Baseline.runBaseline("api/tsserverlibrary.d.ts", () => Harness.IO.readFile("built/local/tsserverlibrary.d.ts"));
|
||||
|
||||
describe("for the language server", () => {
|
||||
verifyApi("tsserverlibrary.d.ts");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -296,7 +296,7 @@ namespace ts.server {
|
||||
}
|
||||
}
|
||||
|
||||
getCancellationToken() {
|
||||
getCancellationToken(): HostCancellationToken {
|
||||
return this.cancellationToken;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user