mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
[Transforms] Merge master on 08/05 (#10182)
* Fix #10083 - allowSyntheticDefaultImports alters getExternalModuleMember (#10096) * Add a helper function `getOrUpdateProperty` to prevent unprotected access to Maps. * Limit type guards as assertions to incomplete types in loops * Accept new baselines * Fix linting error * [Release-2.0] Fix 9662: Visual Studio 2015 with TS2.0 gives incorrect @types path resolution errors (#9867) * Change the shape of the shim layer to support getAutomaticTypeDirectives * Change the key for looking up automatic type-directives * Update baselines from change look-up name of type-directives * Add @currentDirectory into the test * Update baselines * Fix linting error * Address PR: fix spelling mistake * Instead of return path of the type directive names just return type directive names * Remove unused reference files: these tests produce erros so they will not produce these files (#9233) * Don't allow properties inherited from Object to be automatically included in TSX attributes * Port PR #10016 to Master (#10100) * Treat namespaceExportDeclaration as declaration * Update baselines * wip - add tests * Add tests * Show "export namespace" for quick-info * Update baselines from merging
This commit is contained in:
+54
-32
@@ -216,7 +216,7 @@ namespace ts {
|
||||
const flowLoopKeys: string[] = [];
|
||||
const flowLoopTypes: Type[][] = [];
|
||||
const visitedFlowNodes: FlowNode[] = [];
|
||||
const visitedFlowTypes: Type[] = [];
|
||||
const visitedFlowTypes: FlowType[] = [];
|
||||
const potentialThisCollisions: Node[] = [];
|
||||
const awaitedTypeStack: number[] = [];
|
||||
|
||||
@@ -1136,6 +1136,10 @@ namespace ts {
|
||||
else {
|
||||
symbolFromVariable = getPropertyOfVariable(targetSymbol, name.text);
|
||||
}
|
||||
// If the export member we're looking for is default, and there is no real default but allowSyntheticDefaultImports is on, return the entire module as the default
|
||||
if (!symbolFromVariable && allowSyntheticDefaultImports && name.text === "default") {
|
||||
symbolFromVariable = resolveExternalModuleSymbol(moduleSymbol) || resolveSymbol(moduleSymbol);
|
||||
}
|
||||
// if symbolFromVariable is export - get its final target
|
||||
symbolFromVariable = resolveSymbol(symbolFromVariable);
|
||||
const symbolFromModule = getExportOfModule(targetSymbol, name.text);
|
||||
@@ -8094,6 +8098,18 @@ namespace ts {
|
||||
f(type) ? type : neverType;
|
||||
}
|
||||
|
||||
function isIncomplete(flowType: FlowType) {
|
||||
return flowType.flags === 0;
|
||||
}
|
||||
|
||||
function getTypeFromFlowType(flowType: FlowType) {
|
||||
return flowType.flags === 0 ? (<IncompleteType>flowType).type : <Type>flowType;
|
||||
}
|
||||
|
||||
function createFlowType(type: Type, incomplete: boolean): FlowType {
|
||||
return incomplete ? { flags: 0, type } : type;
|
||||
}
|
||||
|
||||
function getFlowTypeOfReference(reference: Node, declaredType: Type, assumeInitialized: boolean, includeOuterFunctions: boolean) {
|
||||
let key: string;
|
||||
if (!reference.flowNode || assumeInitialized && !(declaredType.flags & TypeFlags.Narrowable)) {
|
||||
@@ -8101,14 +8117,14 @@ namespace ts {
|
||||
}
|
||||
const initialType = assumeInitialized ? declaredType : includeFalsyTypes(declaredType, TypeFlags.Undefined);
|
||||
const visitedFlowStart = visitedFlowCount;
|
||||
const result = getTypeAtFlowNode(reference.flowNode);
|
||||
const result = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode));
|
||||
visitedFlowCount = visitedFlowStart;
|
||||
if (reference.parent.kind === SyntaxKind.NonNullExpression && getTypeWithFacts(result, TypeFacts.NEUndefinedOrNull) === neverType) {
|
||||
return declaredType;
|
||||
}
|
||||
return result;
|
||||
|
||||
function getTypeAtFlowNode(flow: FlowNode): Type {
|
||||
function getTypeAtFlowNode(flow: FlowNode): FlowType {
|
||||
while (true) {
|
||||
if (flow.flags & FlowFlags.Shared) {
|
||||
// We cache results of flow type resolution for shared nodes that were previously visited in
|
||||
@@ -8120,7 +8136,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
}
|
||||
let type: Type;
|
||||
let type: FlowType;
|
||||
if (flow.flags & FlowFlags.Assignment) {
|
||||
type = getTypeAtFlowAssignment(<FlowAssignment>flow);
|
||||
if (!type) {
|
||||
@@ -8188,41 +8204,44 @@ namespace ts {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function getTypeAtFlowCondition(flow: FlowCondition) {
|
||||
let type = getTypeAtFlowNode(flow.antecedent);
|
||||
function getTypeAtFlowCondition(flow: FlowCondition): FlowType {
|
||||
const flowType = getTypeAtFlowNode(flow.antecedent);
|
||||
let type = getTypeFromFlowType(flowType);
|
||||
if (type !== neverType) {
|
||||
// If we have an antecedent type (meaning we're reachable in some way), we first
|
||||
// attempt to narrow the antecedent type. If that produces the nothing type, then
|
||||
// we take the type guard as an indication that control could reach here in a
|
||||
// manner not understood by the control flow analyzer (e.g. a function argument
|
||||
// has an invalid type, or a nested function has possibly made an assignment to a
|
||||
// captured variable). We proceed by reverting to the declared type and then
|
||||
// attempt to narrow the antecedent type. If that produces the never type, and if
|
||||
// the antecedent type is incomplete (i.e. a transient type in a loop), then we
|
||||
// take the type guard as an indication that control *could* reach here once we
|
||||
// have the complete type. We proceed by reverting to the declared type and then
|
||||
// narrow that.
|
||||
const assumeTrue = (flow.flags & FlowFlags.TrueCondition) !== 0;
|
||||
type = narrowType(type, flow.expression, assumeTrue);
|
||||
if (type === neverType) {
|
||||
if (type === neverType && isIncomplete(flowType)) {
|
||||
type = narrowType(declaredType, flow.expression, assumeTrue);
|
||||
}
|
||||
}
|
||||
return type;
|
||||
return createFlowType(type, isIncomplete(flowType));
|
||||
}
|
||||
|
||||
function getTypeAtSwitchClause(flow: FlowSwitchClause) {
|
||||
const type = getTypeAtFlowNode(flow.antecedent);
|
||||
function getTypeAtSwitchClause(flow: FlowSwitchClause): FlowType {
|
||||
const flowType = getTypeAtFlowNode(flow.antecedent);
|
||||
let type = getTypeFromFlowType(flowType);
|
||||
const expr = flow.switchStatement.expression;
|
||||
if (isMatchingReference(reference, expr)) {
|
||||
return narrowTypeBySwitchOnDiscriminant(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
|
||||
type = narrowTypeBySwitchOnDiscriminant(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
|
||||
}
|
||||
if (isMatchingPropertyAccess(expr)) {
|
||||
return narrowTypeByDiscriminant(type, <PropertyAccessExpression>expr, t => narrowTypeBySwitchOnDiscriminant(t, flow.switchStatement, flow.clauseStart, flow.clauseEnd));
|
||||
else if (isMatchingPropertyAccess(expr)) {
|
||||
type = narrowTypeByDiscriminant(type, <PropertyAccessExpression>expr, t => narrowTypeBySwitchOnDiscriminant(t, flow.switchStatement, flow.clauseStart, flow.clauseEnd));
|
||||
}
|
||||
return type;
|
||||
return createFlowType(type, isIncomplete(flowType));
|
||||
}
|
||||
|
||||
function getTypeAtFlowBranchLabel(flow: FlowLabel) {
|
||||
function getTypeAtFlowBranchLabel(flow: FlowLabel): FlowType {
|
||||
const antecedentTypes: Type[] = [];
|
||||
let seenIncomplete = false;
|
||||
for (const antecedent of flow.antecedents) {
|
||||
const type = getTypeAtFlowNode(antecedent);
|
||||
const flowType = getTypeAtFlowNode(antecedent);
|
||||
const type = getTypeFromFlowType(flowType);
|
||||
// If the type at a particular antecedent path is the declared type and the
|
||||
// reference is known to always be assigned (i.e. when declared and initial types
|
||||
// are the same), there is no reason to process more antecedents since the only
|
||||
@@ -8233,11 +8252,14 @@ namespace ts {
|
||||
if (!contains(antecedentTypes, type)) {
|
||||
antecedentTypes.push(type);
|
||||
}
|
||||
if (isIncomplete(flowType)) {
|
||||
seenIncomplete = true;
|
||||
}
|
||||
}
|
||||
return getUnionType(antecedentTypes);
|
||||
return createFlowType(getUnionType(antecedentTypes), seenIncomplete);
|
||||
}
|
||||
|
||||
function getTypeAtFlowLoopLabel(flow: FlowLabel) {
|
||||
function getTypeAtFlowLoopLabel(flow: FlowLabel): FlowType {
|
||||
// If we have previously computed the control flow type for the reference at
|
||||
// this flow loop junction, return the cached type.
|
||||
const id = getFlowNodeId(flow);
|
||||
@@ -8249,12 +8271,12 @@ namespace ts {
|
||||
return cache[key];
|
||||
}
|
||||
// If this flow loop junction and reference are already being processed, return
|
||||
// the union of the types computed for each branch so far. We should never see
|
||||
// an empty array here because the first antecedent of a loop junction is always
|
||||
// the non-looping control flow path that leads to the top.
|
||||
// the union of the types computed for each branch so far, marked as incomplete.
|
||||
// We should never see an empty array here because the first antecedent of a loop
|
||||
// junction is always the non-looping control flow path that leads to the top.
|
||||
for (let i = flowLoopStart; i < flowLoopCount; i++) {
|
||||
if (flowLoopNodes[i] === flow && flowLoopKeys[i] === key) {
|
||||
return getUnionType(flowLoopTypes[i]);
|
||||
return createFlowType(getUnionType(flowLoopTypes[i]), /*incomplete*/ true);
|
||||
}
|
||||
}
|
||||
// Add the flow loop junction and reference to the in-process stack and analyze
|
||||
@@ -8265,7 +8287,7 @@ namespace ts {
|
||||
flowLoopTypes[flowLoopCount] = antecedentTypes;
|
||||
for (const antecedent of flow.antecedents) {
|
||||
flowLoopCount++;
|
||||
const type = getTypeAtFlowNode(antecedent);
|
||||
const type = getTypeFromFlowType(getTypeAtFlowNode(antecedent));
|
||||
flowLoopCount--;
|
||||
// If we see a value appear in the cache it is a sign that control flow analysis
|
||||
// was restarted and completed by checkExpressionCached. We can simply pick up
|
||||
@@ -10068,7 +10090,7 @@ namespace ts {
|
||||
for (const prop of props) {
|
||||
// Is there a corresponding property in the element attributes type? Skip checking of properties
|
||||
// that have already been assigned to, as these are not actually pushed into the resulting type
|
||||
if (!nameTable[prop.name]) {
|
||||
if (!hasProperty(nameTable, prop.name)) {
|
||||
const targetPropSym = getPropertyOfType(elementAttributesType, prop.name);
|
||||
if (targetPropSym) {
|
||||
const msg = chainDiagnosticMessages(undefined, Diagnostics.Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property, prop.name);
|
||||
@@ -10414,7 +10436,7 @@ namespace ts {
|
||||
const targetProperties = getPropertiesOfType(targetAttributesType);
|
||||
for (let i = 0; i < targetProperties.length; i++) {
|
||||
if (!(targetProperties[i].flags & SymbolFlags.Optional) &&
|
||||
nameTable[targetProperties[i].name] === undefined) {
|
||||
!hasProperty(nameTable, targetProperties[i].name)) {
|
||||
|
||||
error(node, Diagnostics.Property_0_is_missing_in_type_1, targetProperties[i].name, typeToString(targetAttributesType));
|
||||
}
|
||||
@@ -19845,7 +19867,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function checkGrammarTopLevelElementForRequiredDeclareModifier(node: Node): boolean {
|
||||
// A declare modifier is required for any top level .d.ts declaration except export=, export default,
|
||||
// A declare modifier is required for any top level .d.ts declaration except export=, export default, export as namespace
|
||||
// interfaces and imports categories:
|
||||
//
|
||||
// DeclarationElement:
|
||||
@@ -19863,8 +19885,8 @@ namespace ts {
|
||||
node.kind === SyntaxKind.ImportEqualsDeclaration ||
|
||||
node.kind === SyntaxKind.ExportDeclaration ||
|
||||
node.kind === SyntaxKind.ExportAssignment ||
|
||||
node.kind === SyntaxKind.NamespaceExportDeclaration ||
|
||||
getModifierFlags(node) & (ModifierFlags.Ambient | ModifierFlags.Export | ModifierFlags.Default)) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -499,8 +499,12 @@ namespace ts {
|
||||
return keys;
|
||||
}
|
||||
|
||||
export function getProperty<T>(map: Map<T>, key: string): T {
|
||||
return hasOwnProperty.call(map, key) ? map[key] : undefined;
|
||||
export function getProperty<T>(map: Map<T>, key: string): T | undefined {
|
||||
return hasProperty(map, key) ? map[key] : undefined;
|
||||
}
|
||||
|
||||
export function getOrUpdateProperty<T>(map: Map<T>, key: string, makeValue: () => T): T {
|
||||
return hasProperty(map, key) ? map[key] : map[key] = makeValue();
|
||||
}
|
||||
|
||||
export function isEmpty<T>(map: Map<T>) {
|
||||
|
||||
+9
-10
@@ -1056,19 +1056,15 @@ namespace ts {
|
||||
return resolutions;
|
||||
}
|
||||
|
||||
function getInferredTypesRoot(options: CompilerOptions, rootFiles: string[], host: CompilerHost) {
|
||||
return computeCommonSourceDirectoryOfFilenames(rootFiles, host.getCurrentDirectory(), f => host.getCanonicalFileName(f));
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a set of options and a set of root files, returns the set of type directive names
|
||||
* Given a set of options, returns the set of type directive names
|
||||
* that should be included for this program automatically.
|
||||
* This list could either come from the config file,
|
||||
* or from enumerating the types root + initial secondary types lookup location.
|
||||
* More type directives might appear in the program later as a result of loading actual source files;
|
||||
* this list is only the set of defaults that are implicitly included.
|
||||
*/
|
||||
export function getAutomaticTypeDirectiveNames(options: CompilerOptions, rootFiles: string[], host: CompilerHost): string[] {
|
||||
export function getAutomaticTypeDirectiveNames(options: CompilerOptions, host: ModuleResolutionHost): string[] {
|
||||
// Use explicit type list from tsconfig.json
|
||||
if (options.types) {
|
||||
return options.types;
|
||||
@@ -1081,7 +1077,10 @@ namespace ts {
|
||||
if (typeRoots) {
|
||||
for (const root of typeRoots) {
|
||||
if (host.directoryExists(root)) {
|
||||
result = result.concat(host.getDirectories(root));
|
||||
for (const typeDirectivePath of host.getDirectories(root)) {
|
||||
// Return just the type directive names
|
||||
result = result.concat(getBaseFileName(normalizePath(typeDirectivePath)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1156,11 +1155,11 @@ namespace ts {
|
||||
forEach(rootNames, name => processRootFile(name, /*isDefaultLib*/ false));
|
||||
|
||||
// load type declarations specified via 'types' argument or implicitly from types/ and node_modules/@types folders
|
||||
const typeReferences: string[] = getAutomaticTypeDirectiveNames(options, rootNames, host);
|
||||
const typeReferences: string[] = getAutomaticTypeDirectiveNames(options, host);
|
||||
|
||||
if (typeReferences) {
|
||||
const inferredRoot = getInferredTypesRoot(options, rootNames, host);
|
||||
const containingFilename = combinePaths(inferredRoot, "__inferred type names__.ts");
|
||||
// This containingFilename needs to match with the one used in managed-side
|
||||
const containingFilename = combinePaths(host.getCurrentDirectory(), "__inferred type names__.ts");
|
||||
const resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, containingFilename);
|
||||
for (let i = 0; i < typeReferences.length; i++) {
|
||||
processTypeReferenceDirective(typeReferences[i], resolutions[i]);
|
||||
|
||||
@@ -1680,6 +1680,16 @@ namespace ts {
|
||||
antecedent: FlowNode;
|
||||
}
|
||||
|
||||
export type FlowType = Type | IncompleteType;
|
||||
|
||||
// Incomplete types occur during control flow analysis of loops. An IncompleteType
|
||||
// is distinguished from a regular type by a flags value of zero. Incomplete type
|
||||
// objects are internal to the getFlowTypeOfRefecence function and never escape it.
|
||||
export interface IncompleteType {
|
||||
flags: TypeFlags; // No flags set
|
||||
type: Type; // The type marked incomplete
|
||||
}
|
||||
|
||||
export interface AmdDependency {
|
||||
path: string;
|
||||
name: string;
|
||||
@@ -2978,6 +2988,7 @@ namespace ts {
|
||||
directoryExists?(directoryName: string): boolean;
|
||||
realpath?(path: string): string;
|
||||
getCurrentDirectory?(): string;
|
||||
getDirectories?(path: string): string[];
|
||||
}
|
||||
|
||||
export interface ResolvedModule {
|
||||
|
||||
@@ -3521,12 +3521,7 @@ namespace ts {
|
||||
// export { x, y }
|
||||
for (const specifier of (<ExportDeclaration>node).exportClause.elements) {
|
||||
const name = (specifier.propertyName || specifier.name).text;
|
||||
if (!exportSpecifiers[name]) {
|
||||
exportSpecifiers[name] = [specifier];
|
||||
}
|
||||
else {
|
||||
exportSpecifiers[name].push(specifier);
|
||||
}
|
||||
getOrUpdateProperty(exportSpecifiers, name, () => []).push(specifier);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -3965,6 +3960,7 @@ namespace ts {
|
||||
|| kind === SyntaxKind.MethodDeclaration
|
||||
|| kind === SyntaxKind.MethodSignature
|
||||
|| kind === SyntaxKind.ModuleDeclaration
|
||||
|| kind === SyntaxKind.NamespaceExportDeclaration
|
||||
|| kind === SyntaxKind.NamespaceImport
|
||||
|| kind === SyntaxKind.Parameter
|
||||
|| kind === SyntaxKind.PropertyAssignment
|
||||
|
||||
@@ -1891,7 +1891,7 @@ namespace ts {
|
||||
};
|
||||
}
|
||||
|
||||
// Cache host information about scrip Should be refreshed
|
||||
// Cache host information about script should be refreshed
|
||||
// at each language service public entry point, since we don't know when
|
||||
// set of scripts handled by the host changes.
|
||||
class HostCache {
|
||||
@@ -4835,7 +4835,14 @@ namespace ts {
|
||||
}
|
||||
if (symbolFlags & SymbolFlags.Alias) {
|
||||
addNewLineIfDisplayPartsExist();
|
||||
displayParts.push(keywordPart(SyntaxKind.ImportKeyword));
|
||||
if (symbol.declarations[0].kind === SyntaxKind.NamespaceExportDeclaration) {
|
||||
displayParts.push(keywordPart(SyntaxKind.ExportKeyword));
|
||||
displayParts.push(spacePart());
|
||||
displayParts.push(keywordPart(SyntaxKind.NamespaceKeyword));
|
||||
}
|
||||
else {
|
||||
displayParts.push(keywordPart(SyntaxKind.ImportKeyword));
|
||||
}
|
||||
displayParts.push(spacePart());
|
||||
addFullSymbolName(symbol);
|
||||
ts.forEach(symbol.declarations, declaration => {
|
||||
|
||||
+30
-5
@@ -72,8 +72,13 @@ namespace ts {
|
||||
directoryExists(directoryName: string): boolean;
|
||||
}
|
||||
|
||||
/** Public interface of the the of a config service shim instance.*/
|
||||
export interface CoreServicesShimHost extends Logger, ModuleResolutionHost {
|
||||
/** Public interface of the core-services host instance used in managed side */
|
||||
export interface CoreServicesShimHost extends Logger {
|
||||
directoryExists(directoryName: string): boolean;
|
||||
fileExists(fileName: string): boolean;
|
||||
getCurrentDirectory(): string;
|
||||
getDirectories(path: string): string;
|
||||
|
||||
/**
|
||||
* Returns a JSON-encoded value of the type: string[]
|
||||
*
|
||||
@@ -81,9 +86,14 @@ namespace ts {
|
||||
* when enumerating the directory.
|
||||
*/
|
||||
readDirectory(rootDir: string, extension: string, basePaths?: string, excludeEx?: string, includeFileEx?: string, includeDirEx?: string, depth?: number): string;
|
||||
useCaseSensitiveFileNames?(): boolean;
|
||||
getCurrentDirectory(): string;
|
||||
|
||||
/**
|
||||
* Read arbitary text files on disk, i.e. when resolution procedure needs the content of 'package.json' to determine location of bundled typings for node modules
|
||||
*/
|
||||
readFile(fileName: string): string;
|
||||
realpath?(path: string): string;
|
||||
trace(s: string): void;
|
||||
useCaseSensitiveFileNames?(): boolean;
|
||||
}
|
||||
|
||||
///
|
||||
@@ -240,6 +250,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
export interface CoreServicesShim extends Shim {
|
||||
getAutomaticTypeDirectiveNames(compilerOptionsJson: string): string;
|
||||
getPreProcessedFileInfo(fileName: string, sourceText: IScriptSnapshot): string;
|
||||
getTSConfigFileInfo(fileName: string, sourceText: IScriptSnapshot): string;
|
||||
getDefaultCompilationSettings(): string;
|
||||
@@ -492,6 +503,10 @@ namespace ts {
|
||||
private readDirectoryFallback(rootDir: string, extension: string, exclude: string[]) {
|
||||
return JSON.parse(this.shimHost.readDirectory(rootDir, extension, JSON.stringify(exclude)));
|
||||
}
|
||||
|
||||
public getDirectories(path: string): string[] {
|
||||
return JSON.parse(this.shimHost.getDirectories(path));
|
||||
}
|
||||
}
|
||||
|
||||
function simpleForwardCall(logger: Logger, actionDescription: string, action: () => any, logPerformance: boolean): any {
|
||||
@@ -1003,7 +1018,7 @@ namespace ts {
|
||||
|
||||
public getPreProcessedFileInfo(fileName: string, sourceTextSnapshot: IScriptSnapshot): string {
|
||||
return this.forwardJSONCall(
|
||||
"getPreProcessedFileInfo('" + fileName + "')",
|
||||
`getPreProcessedFileInfo('${fileName}')`,
|
||||
() => {
|
||||
// for now treat files as JavaScript
|
||||
const result = preProcessFile(sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength()), /* readImportFiles */ true, /* detectJavaScriptImports */ true);
|
||||
@@ -1017,6 +1032,16 @@ namespace ts {
|
||||
});
|
||||
}
|
||||
|
||||
public getAutomaticTypeDirectiveNames(compilerOptionsJson: string): string {
|
||||
return this.forwardJSONCall(
|
||||
`getAutomaticTypeDirectiveNames('${compilerOptionsJson}')`,
|
||||
() => {
|
||||
const compilerOptions = <CompilerOptions>JSON.parse(compilerOptionsJson);
|
||||
return getAutomaticTypeDirectiveNames(compilerOptions, this.host);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
private convertFileReferences(refs: FileReference[]): IFileReference[] {
|
||||
if (!refs) {
|
||||
return undefined;
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
tests/cases/compiler/a.ts(2,5): error TS2339: Property 'default' does not exist on type 'typeof "tests/cases/compiler/b"'.
|
||||
tests/cases/compiler/a.ts(3,5): error TS2339: Property 'default' does not exist on type 'typeof "tests/cases/compiler/b"'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/a.ts (2 errors) ====
|
||||
import Foo = require("./b");
|
||||
Foo.default.bar();
|
||||
~~~~~~~
|
||||
!!! error TS2339: Property 'default' does not exist on type 'typeof "tests/cases/compiler/b"'.
|
||||
Foo.default.default.foo();
|
||||
~~~~~~~
|
||||
!!! error TS2339: Property 'default' does not exist on type 'typeof "tests/cases/compiler/b"'.
|
||||
==== tests/cases/compiler/b.d.ts (0 errors) ====
|
||||
export function foo();
|
||||
|
||||
export function bar();
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
//// [tests/cases/compiler/allowSyntheticDefaultImports10.ts] ////
|
||||
|
||||
//// [b.d.ts]
|
||||
export function foo();
|
||||
|
||||
export function bar();
|
||||
|
||||
//// [a.ts]
|
||||
import Foo = require("./b");
|
||||
Foo.default.bar();
|
||||
Foo.default.default.foo();
|
||||
|
||||
//// [a.js]
|
||||
"use strict";
|
||||
var Foo = require("./b");
|
||||
Foo.default.bar();
|
||||
Foo.default.default.foo();
|
||||
@@ -0,0 +1,29 @@
|
||||
//// [tests/cases/compiler/allowSyntheticDefaultImports7.ts] ////
|
||||
|
||||
//// [b.d.ts]
|
||||
export function foo();
|
||||
|
||||
export function bar();
|
||||
|
||||
//// [a.ts]
|
||||
import { default as Foo } from "./b";
|
||||
Foo.bar();
|
||||
Foo.foo();
|
||||
|
||||
//// [a.js]
|
||||
System.register(["./b"], function (exports_1, context_1) {
|
||||
"use strict";
|
||||
var __moduleName = context_1 && context_1.id;
|
||||
var b_1;
|
||||
return {
|
||||
setters: [
|
||||
function (b_1_1) {
|
||||
b_1 = b_1_1;
|
||||
}
|
||||
],
|
||||
execute: function () {
|
||||
b_1["default"].bar();
|
||||
b_1["default"].foo();
|
||||
}
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,22 @@
|
||||
=== tests/cases/compiler/b.d.ts ===
|
||||
export function foo();
|
||||
>foo : Symbol(foo, Decl(b.d.ts, 0, 0))
|
||||
|
||||
export function bar();
|
||||
>bar : Symbol(bar, Decl(b.d.ts, 0, 22))
|
||||
|
||||
=== tests/cases/compiler/a.ts ===
|
||||
import { default as Foo } from "./b";
|
||||
>default : Symbol(Foo, Decl(a.ts, 0, 8))
|
||||
>Foo : Symbol(Foo, Decl(a.ts, 0, 8))
|
||||
|
||||
Foo.bar();
|
||||
>Foo.bar : Symbol(Foo.bar, Decl(b.d.ts, 0, 22))
|
||||
>Foo : Symbol(Foo, Decl(a.ts, 0, 8))
|
||||
>bar : Symbol(Foo.bar, Decl(b.d.ts, 0, 22))
|
||||
|
||||
Foo.foo();
|
||||
>Foo.foo : Symbol(Foo.foo, Decl(b.d.ts, 0, 0))
|
||||
>Foo : Symbol(Foo, Decl(a.ts, 0, 8))
|
||||
>foo : Symbol(Foo.foo, Decl(b.d.ts, 0, 0))
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
=== tests/cases/compiler/b.d.ts ===
|
||||
export function foo();
|
||||
>foo : () => any
|
||||
|
||||
export function bar();
|
||||
>bar : () => any
|
||||
|
||||
=== tests/cases/compiler/a.ts ===
|
||||
import { default as Foo } from "./b";
|
||||
>default : typeof Foo
|
||||
>Foo : typeof Foo
|
||||
|
||||
Foo.bar();
|
||||
>Foo.bar() : any
|
||||
>Foo.bar : () => any
|
||||
>Foo : typeof Foo
|
||||
>bar : () => any
|
||||
|
||||
Foo.foo();
|
||||
>Foo.foo() : any
|
||||
>Foo.foo : () => any
|
||||
>Foo : typeof Foo
|
||||
>foo : () => any
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
tests/cases/compiler/a.ts(1,10): error TS2305: Module '"tests/cases/compiler/b"' has no exported member 'default'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/b.d.ts (0 errors) ====
|
||||
export function foo();
|
||||
|
||||
export function bar();
|
||||
|
||||
==== tests/cases/compiler/a.ts (1 errors) ====
|
||||
import { default as Foo } from "./b";
|
||||
~~~~~~~
|
||||
!!! error TS2305: Module '"tests/cases/compiler/b"' has no exported member 'default'.
|
||||
Foo.bar();
|
||||
Foo.foo();
|
||||
@@ -0,0 +1,29 @@
|
||||
//// [tests/cases/compiler/allowSyntheticDefaultImports8.ts] ////
|
||||
|
||||
//// [b.d.ts]
|
||||
export function foo();
|
||||
|
||||
export function bar();
|
||||
|
||||
//// [a.ts]
|
||||
import { default as Foo } from "./b";
|
||||
Foo.bar();
|
||||
Foo.foo();
|
||||
|
||||
//// [a.js]
|
||||
System.register(["./b"], function (exports_1, context_1) {
|
||||
"use strict";
|
||||
var __moduleName = context_1 && context_1.id;
|
||||
var b_1;
|
||||
return {
|
||||
setters: [
|
||||
function (b_1_1) {
|
||||
b_1 = b_1_1;
|
||||
}
|
||||
],
|
||||
execute: function () {
|
||||
b_1["default"].bar();
|
||||
b_1["default"].foo();
|
||||
}
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,17 @@
|
||||
//// [tests/cases/compiler/allowSyntheticDefaultImports9.ts] ////
|
||||
|
||||
//// [b.d.ts]
|
||||
export function foo();
|
||||
|
||||
export function bar();
|
||||
|
||||
//// [a.ts]
|
||||
import { default as Foo } from "./b";
|
||||
Foo.bar();
|
||||
Foo.foo();
|
||||
|
||||
//// [a.js]
|
||||
"use strict";
|
||||
var b_1 = require("./b");
|
||||
b_1["default"].bar();
|
||||
b_1["default"].foo();
|
||||
@@ -0,0 +1,22 @@
|
||||
=== tests/cases/compiler/b.d.ts ===
|
||||
export function foo();
|
||||
>foo : Symbol(foo, Decl(b.d.ts, 0, 0))
|
||||
|
||||
export function bar();
|
||||
>bar : Symbol(bar, Decl(b.d.ts, 0, 22))
|
||||
|
||||
=== tests/cases/compiler/a.ts ===
|
||||
import { default as Foo } from "./b";
|
||||
>default : Symbol(Foo, Decl(a.ts, 0, 8))
|
||||
>Foo : Symbol(Foo, Decl(a.ts, 0, 8))
|
||||
|
||||
Foo.bar();
|
||||
>Foo.bar : Symbol(Foo.bar, Decl(b.d.ts, 0, 22))
|
||||
>Foo : Symbol(Foo, Decl(a.ts, 0, 8))
|
||||
>bar : Symbol(Foo.bar, Decl(b.d.ts, 0, 22))
|
||||
|
||||
Foo.foo();
|
||||
>Foo.foo : Symbol(Foo.foo, Decl(b.d.ts, 0, 0))
|
||||
>Foo : Symbol(Foo, Decl(a.ts, 0, 8))
|
||||
>foo : Symbol(Foo.foo, Decl(b.d.ts, 0, 0))
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
=== tests/cases/compiler/b.d.ts ===
|
||||
export function foo();
|
||||
>foo : () => any
|
||||
|
||||
export function bar();
|
||||
>bar : () => any
|
||||
|
||||
=== tests/cases/compiler/a.ts ===
|
||||
import { default as Foo } from "./b";
|
||||
>default : typeof Foo
|
||||
>Foo : typeof Foo
|
||||
|
||||
Foo.bar();
|
||||
>Foo.bar() : any
|
||||
>Foo.bar : () => any
|
||||
>Foo : typeof Foo
|
||||
>bar : () => any
|
||||
|
||||
Foo.foo();
|
||||
>Foo.foo() : any
|
||||
>Foo.foo : () => any
|
||||
>Foo : typeof Foo
|
||||
>foo : () => any
|
||||
|
||||
@@ -1,402 +0,0 @@
|
||||
=== tests/cases/conformance/types/union/discriminatedUnionTypes1.ts ===
|
||||
interface Square {
|
||||
>Square : Symbol(Square, Decl(discriminatedUnionTypes1.ts, 0, 0))
|
||||
|
||||
kind: "square";
|
||||
>kind : Symbol(Square.kind, Decl(discriminatedUnionTypes1.ts, 0, 18))
|
||||
|
||||
size: number;
|
||||
>size : Symbol(Square.size, Decl(discriminatedUnionTypes1.ts, 1, 19))
|
||||
}
|
||||
|
||||
interface Rectangle {
|
||||
>Rectangle : Symbol(Rectangle, Decl(discriminatedUnionTypes1.ts, 3, 1))
|
||||
|
||||
kind: "rectangle";
|
||||
>kind : Symbol(Rectangle.kind, Decl(discriminatedUnionTypes1.ts, 5, 21))
|
||||
|
||||
width: number;
|
||||
>width : Symbol(Rectangle.width, Decl(discriminatedUnionTypes1.ts, 6, 22))
|
||||
|
||||
height: number;
|
||||
>height : Symbol(Rectangle.height, Decl(discriminatedUnionTypes1.ts, 7, 18))
|
||||
}
|
||||
|
||||
interface Circle {
|
||||
>Circle : Symbol(Circle, Decl(discriminatedUnionTypes1.ts, 9, 1))
|
||||
|
||||
kind: "circle";
|
||||
>kind : Symbol(Circle.kind, Decl(discriminatedUnionTypes1.ts, 11, 18))
|
||||
|
||||
radius: number;
|
||||
>radius : Symbol(Circle.radius, Decl(discriminatedUnionTypes1.ts, 12, 19))
|
||||
}
|
||||
|
||||
type Shape = Square | Rectangle | Circle;
|
||||
>Shape : Symbol(Shape, Decl(discriminatedUnionTypes1.ts, 14, 1))
|
||||
>Square : Symbol(Square, Decl(discriminatedUnionTypes1.ts, 0, 0))
|
||||
>Rectangle : Symbol(Rectangle, Decl(discriminatedUnionTypes1.ts, 3, 1))
|
||||
>Circle : Symbol(Circle, Decl(discriminatedUnionTypes1.ts, 9, 1))
|
||||
|
||||
function area1(s: Shape) {
|
||||
>area1 : Symbol(area1, Decl(discriminatedUnionTypes1.ts, 16, 41))
|
||||
>s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 18, 15))
|
||||
>Shape : Symbol(Shape, Decl(discriminatedUnionTypes1.ts, 14, 1))
|
||||
|
||||
if (s.kind === "square") {
|
||||
>s.kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 0, 18), Decl(discriminatedUnionTypes1.ts, 5, 21), Decl(discriminatedUnionTypes1.ts, 11, 18))
|
||||
>s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 18, 15))
|
||||
>kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 0, 18), Decl(discriminatedUnionTypes1.ts, 5, 21), Decl(discriminatedUnionTypes1.ts, 11, 18))
|
||||
|
||||
return s.size * s.size;
|
||||
>s.size : Symbol(Square.size, Decl(discriminatedUnionTypes1.ts, 1, 19))
|
||||
>s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 18, 15))
|
||||
>size : Symbol(Square.size, Decl(discriminatedUnionTypes1.ts, 1, 19))
|
||||
>s.size : Symbol(Square.size, Decl(discriminatedUnionTypes1.ts, 1, 19))
|
||||
>s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 18, 15))
|
||||
>size : Symbol(Square.size, Decl(discriminatedUnionTypes1.ts, 1, 19))
|
||||
}
|
||||
else if (s.kind === "circle") {
|
||||
>s.kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 5, 21), Decl(discriminatedUnionTypes1.ts, 11, 18))
|
||||
>s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 18, 15))
|
||||
>kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 5, 21), Decl(discriminatedUnionTypes1.ts, 11, 18))
|
||||
|
||||
return Math.PI * s.radius * s.radius;
|
||||
>Math.PI : Symbol(Math.PI, Decl(lib.d.ts, --, --))
|
||||
>Math : Symbol(Math, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
>PI : Symbol(Math.PI, Decl(lib.d.ts, --, --))
|
||||
>s.radius : Symbol(Circle.radius, Decl(discriminatedUnionTypes1.ts, 12, 19))
|
||||
>s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 18, 15))
|
||||
>radius : Symbol(Circle.radius, Decl(discriminatedUnionTypes1.ts, 12, 19))
|
||||
>s.radius : Symbol(Circle.radius, Decl(discriminatedUnionTypes1.ts, 12, 19))
|
||||
>s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 18, 15))
|
||||
>radius : Symbol(Circle.radius, Decl(discriminatedUnionTypes1.ts, 12, 19))
|
||||
}
|
||||
else if (s.kind === "rectangle") {
|
||||
>s.kind : Symbol(Rectangle.kind, Decl(discriminatedUnionTypes1.ts, 5, 21))
|
||||
>s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 18, 15))
|
||||
>kind : Symbol(Rectangle.kind, Decl(discriminatedUnionTypes1.ts, 5, 21))
|
||||
|
||||
return s.width * s.height;
|
||||
>s.width : Symbol(Rectangle.width, Decl(discriminatedUnionTypes1.ts, 6, 22))
|
||||
>s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 18, 15))
|
||||
>width : Symbol(Rectangle.width, Decl(discriminatedUnionTypes1.ts, 6, 22))
|
||||
>s.height : Symbol(Rectangle.height, Decl(discriminatedUnionTypes1.ts, 7, 18))
|
||||
>s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 18, 15))
|
||||
>height : Symbol(Rectangle.height, Decl(discriminatedUnionTypes1.ts, 7, 18))
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
function area2(s: Shape) {
|
||||
>area2 : Symbol(area2, Decl(discriminatedUnionTypes1.ts, 31, 1))
|
||||
>s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 33, 15))
|
||||
>Shape : Symbol(Shape, Decl(discriminatedUnionTypes1.ts, 14, 1))
|
||||
|
||||
switch (s.kind) {
|
||||
>s.kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 0, 18), Decl(discriminatedUnionTypes1.ts, 5, 21), Decl(discriminatedUnionTypes1.ts, 11, 18))
|
||||
>s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 33, 15))
|
||||
>kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 0, 18), Decl(discriminatedUnionTypes1.ts, 5, 21), Decl(discriminatedUnionTypes1.ts, 11, 18))
|
||||
|
||||
case "square": return s.size * s.size;
|
||||
>s.size : Symbol(Square.size, Decl(discriminatedUnionTypes1.ts, 1, 19))
|
||||
>s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 33, 15))
|
||||
>size : Symbol(Square.size, Decl(discriminatedUnionTypes1.ts, 1, 19))
|
||||
>s.size : Symbol(Square.size, Decl(discriminatedUnionTypes1.ts, 1, 19))
|
||||
>s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 33, 15))
|
||||
>size : Symbol(Square.size, Decl(discriminatedUnionTypes1.ts, 1, 19))
|
||||
|
||||
case "rectangle": return s.width * s.height;
|
||||
>s.width : Symbol(Rectangle.width, Decl(discriminatedUnionTypes1.ts, 6, 22))
|
||||
>s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 33, 15))
|
||||
>width : Symbol(Rectangle.width, Decl(discriminatedUnionTypes1.ts, 6, 22))
|
||||
>s.height : Symbol(Rectangle.height, Decl(discriminatedUnionTypes1.ts, 7, 18))
|
||||
>s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 33, 15))
|
||||
>height : Symbol(Rectangle.height, Decl(discriminatedUnionTypes1.ts, 7, 18))
|
||||
|
||||
case "circle": return Math.PI * s.radius * s.radius;
|
||||
>Math.PI : Symbol(Math.PI, Decl(lib.d.ts, --, --))
|
||||
>Math : Symbol(Math, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
>PI : Symbol(Math.PI, Decl(lib.d.ts, --, --))
|
||||
>s.radius : Symbol(Circle.radius, Decl(discriminatedUnionTypes1.ts, 12, 19))
|
||||
>s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 33, 15))
|
||||
>radius : Symbol(Circle.radius, Decl(discriminatedUnionTypes1.ts, 12, 19))
|
||||
>s.radius : Symbol(Circle.radius, Decl(discriminatedUnionTypes1.ts, 12, 19))
|
||||
>s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 33, 15))
|
||||
>radius : Symbol(Circle.radius, Decl(discriminatedUnionTypes1.ts, 12, 19))
|
||||
}
|
||||
}
|
||||
|
||||
function assertNever(x: never): never {
|
||||
>assertNever : Symbol(assertNever, Decl(discriminatedUnionTypes1.ts, 39, 1))
|
||||
>x : Symbol(x, Decl(discriminatedUnionTypes1.ts, 41, 21))
|
||||
|
||||
throw new Error("Unexpected object: " + x);
|
||||
>Error : Symbol(Error, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(discriminatedUnionTypes1.ts, 41, 21))
|
||||
}
|
||||
|
||||
function area3(s: Shape) {
|
||||
>area3 : Symbol(area3, Decl(discriminatedUnionTypes1.ts, 43, 1))
|
||||
>s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 45, 15))
|
||||
>Shape : Symbol(Shape, Decl(discriminatedUnionTypes1.ts, 14, 1))
|
||||
|
||||
switch (s.kind) {
|
||||
>s.kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 0, 18), Decl(discriminatedUnionTypes1.ts, 5, 21), Decl(discriminatedUnionTypes1.ts, 11, 18))
|
||||
>s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 45, 15))
|
||||
>kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 0, 18), Decl(discriminatedUnionTypes1.ts, 5, 21), Decl(discriminatedUnionTypes1.ts, 11, 18))
|
||||
|
||||
case "square": return s.size * s.size;
|
||||
>s.size : Symbol(Square.size, Decl(discriminatedUnionTypes1.ts, 1, 19))
|
||||
>s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 45, 15))
|
||||
>size : Symbol(Square.size, Decl(discriminatedUnionTypes1.ts, 1, 19))
|
||||
>s.size : Symbol(Square.size, Decl(discriminatedUnionTypes1.ts, 1, 19))
|
||||
>s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 45, 15))
|
||||
>size : Symbol(Square.size, Decl(discriminatedUnionTypes1.ts, 1, 19))
|
||||
|
||||
case "rectangle": return s.width * s.height;
|
||||
>s.width : Symbol(Rectangle.width, Decl(discriminatedUnionTypes1.ts, 6, 22))
|
||||
>s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 45, 15))
|
||||
>width : Symbol(Rectangle.width, Decl(discriminatedUnionTypes1.ts, 6, 22))
|
||||
>s.height : Symbol(Rectangle.height, Decl(discriminatedUnionTypes1.ts, 7, 18))
|
||||
>s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 45, 15))
|
||||
>height : Symbol(Rectangle.height, Decl(discriminatedUnionTypes1.ts, 7, 18))
|
||||
|
||||
case "circle": return Math.PI * s.radius * s.radius;
|
||||
>Math.PI : Symbol(Math.PI, Decl(lib.d.ts, --, --))
|
||||
>Math : Symbol(Math, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
>PI : Symbol(Math.PI, Decl(lib.d.ts, --, --))
|
||||
>s.radius : Symbol(Circle.radius, Decl(discriminatedUnionTypes1.ts, 12, 19))
|
||||
>s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 45, 15))
|
||||
>radius : Symbol(Circle.radius, Decl(discriminatedUnionTypes1.ts, 12, 19))
|
||||
>s.radius : Symbol(Circle.radius, Decl(discriminatedUnionTypes1.ts, 12, 19))
|
||||
>s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 45, 15))
|
||||
>radius : Symbol(Circle.radius, Decl(discriminatedUnionTypes1.ts, 12, 19))
|
||||
|
||||
default: return assertNever(s);
|
||||
>assertNever : Symbol(assertNever, Decl(discriminatedUnionTypes1.ts, 39, 1))
|
||||
>s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 45, 15))
|
||||
}
|
||||
}
|
||||
|
||||
function area4(s: Shape) {
|
||||
>area4 : Symbol(area4, Decl(discriminatedUnionTypes1.ts, 52, 1))
|
||||
>s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 54, 15))
|
||||
>Shape : Symbol(Shape, Decl(discriminatedUnionTypes1.ts, 14, 1))
|
||||
|
||||
switch (s.kind) {
|
||||
>s.kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 0, 18), Decl(discriminatedUnionTypes1.ts, 5, 21), Decl(discriminatedUnionTypes1.ts, 11, 18))
|
||||
>s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 54, 15))
|
||||
>kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 0, 18), Decl(discriminatedUnionTypes1.ts, 5, 21), Decl(discriminatedUnionTypes1.ts, 11, 18))
|
||||
|
||||
case "square": return s.size * s.size;
|
||||
>s.size : Symbol(Square.size, Decl(discriminatedUnionTypes1.ts, 1, 19))
|
||||
>s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 54, 15))
|
||||
>size : Symbol(Square.size, Decl(discriminatedUnionTypes1.ts, 1, 19))
|
||||
>s.size : Symbol(Square.size, Decl(discriminatedUnionTypes1.ts, 1, 19))
|
||||
>s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 54, 15))
|
||||
>size : Symbol(Square.size, Decl(discriminatedUnionTypes1.ts, 1, 19))
|
||||
|
||||
case "rectangle": return s.width * s.height;
|
||||
>s.width : Symbol(Rectangle.width, Decl(discriminatedUnionTypes1.ts, 6, 22))
|
||||
>s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 54, 15))
|
||||
>width : Symbol(Rectangle.width, Decl(discriminatedUnionTypes1.ts, 6, 22))
|
||||
>s.height : Symbol(Rectangle.height, Decl(discriminatedUnionTypes1.ts, 7, 18))
|
||||
>s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 54, 15))
|
||||
>height : Symbol(Rectangle.height, Decl(discriminatedUnionTypes1.ts, 7, 18))
|
||||
|
||||
case "circle": return Math.PI * s.radius * s.radius;
|
||||
>Math.PI : Symbol(Math.PI, Decl(lib.d.ts, --, --))
|
||||
>Math : Symbol(Math, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
>PI : Symbol(Math.PI, Decl(lib.d.ts, --, --))
|
||||
>s.radius : Symbol(Circle.radius, Decl(discriminatedUnionTypes1.ts, 12, 19))
|
||||
>s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 54, 15))
|
||||
>radius : Symbol(Circle.radius, Decl(discriminatedUnionTypes1.ts, 12, 19))
|
||||
>s.radius : Symbol(Circle.radius, Decl(discriminatedUnionTypes1.ts, 12, 19))
|
||||
>s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 54, 15))
|
||||
>radius : Symbol(Circle.radius, Decl(discriminatedUnionTypes1.ts, 12, 19))
|
||||
}
|
||||
return assertNever(s);
|
||||
>assertNever : Symbol(assertNever, Decl(discriminatedUnionTypes1.ts, 39, 1))
|
||||
>s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 54, 15))
|
||||
}
|
||||
|
||||
type Message =
|
||||
>Message : Symbol(Message, Decl(discriminatedUnionTypes1.ts, 61, 1))
|
||||
|
||||
{ kind: "A", x: string } |
|
||||
>kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 64, 5))
|
||||
>x : Symbol(x, Decl(discriminatedUnionTypes1.ts, 64, 16))
|
||||
|
||||
{ kind: "B" | "C", y: number } |
|
||||
>kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 65, 5))
|
||||
>y : Symbol(y, Decl(discriminatedUnionTypes1.ts, 65, 22))
|
||||
|
||||
{ kind: "D" };
|
||||
>kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 66, 5))
|
||||
|
||||
function f1(m: Message) {
|
||||
>f1 : Symbol(f1, Decl(discriminatedUnionTypes1.ts, 66, 18))
|
||||
>m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 68, 12))
|
||||
>Message : Symbol(Message, Decl(discriminatedUnionTypes1.ts, 61, 1))
|
||||
|
||||
if (m.kind === "A") {
|
||||
>m.kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 64, 5), Decl(discriminatedUnionTypes1.ts, 65, 5), Decl(discriminatedUnionTypes1.ts, 66, 5))
|
||||
>m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 68, 12))
|
||||
>kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 64, 5), Decl(discriminatedUnionTypes1.ts, 65, 5), Decl(discriminatedUnionTypes1.ts, 66, 5))
|
||||
|
||||
m; // { kind: "A", x: string }
|
||||
>m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 68, 12))
|
||||
}
|
||||
else if (m.kind === "D") {
|
||||
>m.kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 65, 5), Decl(discriminatedUnionTypes1.ts, 66, 5))
|
||||
>m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 68, 12))
|
||||
>kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 65, 5), Decl(discriminatedUnionTypes1.ts, 66, 5))
|
||||
|
||||
m; // { kind: "D" }
|
||||
>m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 68, 12))
|
||||
}
|
||||
else {
|
||||
m; // { kind: "B" | "C", y: number }
|
||||
>m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 68, 12))
|
||||
}
|
||||
}
|
||||
|
||||
function f2(m: Message) {
|
||||
>f2 : Symbol(f2, Decl(discriminatedUnionTypes1.ts, 78, 1))
|
||||
>m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 80, 12))
|
||||
>Message : Symbol(Message, Decl(discriminatedUnionTypes1.ts, 61, 1))
|
||||
|
||||
if (m.kind === "A") {
|
||||
>m.kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 64, 5), Decl(discriminatedUnionTypes1.ts, 65, 5), Decl(discriminatedUnionTypes1.ts, 66, 5))
|
||||
>m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 80, 12))
|
||||
>kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 64, 5), Decl(discriminatedUnionTypes1.ts, 65, 5), Decl(discriminatedUnionTypes1.ts, 66, 5))
|
||||
|
||||
return;
|
||||
}
|
||||
m; // { kind: "B" | "C", y: number } | { kind: "D" }
|
||||
>m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 80, 12))
|
||||
}
|
||||
|
||||
function f3(m: Message) {
|
||||
>f3 : Symbol(f3, Decl(discriminatedUnionTypes1.ts, 85, 1))
|
||||
>m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 87, 12))
|
||||
>Message : Symbol(Message, Decl(discriminatedUnionTypes1.ts, 61, 1))
|
||||
|
||||
if (m.kind === "X") {
|
||||
>m.kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 64, 5), Decl(discriminatedUnionTypes1.ts, 65, 5), Decl(discriminatedUnionTypes1.ts, 66, 5))
|
||||
>m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 87, 12))
|
||||
>kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 64, 5), Decl(discriminatedUnionTypes1.ts, 65, 5), Decl(discriminatedUnionTypes1.ts, 66, 5))
|
||||
|
||||
m; // never
|
||||
>m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 87, 12))
|
||||
}
|
||||
}
|
||||
|
||||
function f4(m: Message, x: "A" | "D") {
|
||||
>f4 : Symbol(f4, Decl(discriminatedUnionTypes1.ts, 91, 1))
|
||||
>m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 93, 12))
|
||||
>Message : Symbol(Message, Decl(discriminatedUnionTypes1.ts, 61, 1))
|
||||
>x : Symbol(x, Decl(discriminatedUnionTypes1.ts, 93, 23))
|
||||
|
||||
if (m.kind == x) {
|
||||
>m.kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 64, 5), Decl(discriminatedUnionTypes1.ts, 65, 5), Decl(discriminatedUnionTypes1.ts, 66, 5))
|
||||
>m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 93, 12))
|
||||
>kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 64, 5), Decl(discriminatedUnionTypes1.ts, 65, 5), Decl(discriminatedUnionTypes1.ts, 66, 5))
|
||||
>x : Symbol(x, Decl(discriminatedUnionTypes1.ts, 93, 23))
|
||||
|
||||
m; // { kind: "A", x: string } | { kind: "D" }
|
||||
>m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 93, 12))
|
||||
}
|
||||
}
|
||||
|
||||
function f5(m: Message) {
|
||||
>f5 : Symbol(f5, Decl(discriminatedUnionTypes1.ts, 97, 1))
|
||||
>m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 99, 12))
|
||||
>Message : Symbol(Message, Decl(discriminatedUnionTypes1.ts, 61, 1))
|
||||
|
||||
switch (m.kind) {
|
||||
>m.kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 64, 5), Decl(discriminatedUnionTypes1.ts, 65, 5), Decl(discriminatedUnionTypes1.ts, 66, 5))
|
||||
>m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 99, 12))
|
||||
>kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 64, 5), Decl(discriminatedUnionTypes1.ts, 65, 5), Decl(discriminatedUnionTypes1.ts, 66, 5))
|
||||
|
||||
case "A":
|
||||
m; // { kind: "A", x: string }
|
||||
>m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 99, 12))
|
||||
|
||||
break;
|
||||
case "D":
|
||||
m; // { kind: "D" }
|
||||
>m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 99, 12))
|
||||
|
||||
break;
|
||||
default:
|
||||
m; // { kind: "B" | "C", y: number }
|
||||
>m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 99, 12))
|
||||
}
|
||||
}
|
||||
|
||||
function f6(m: Message) {
|
||||
>f6 : Symbol(f6, Decl(discriminatedUnionTypes1.ts, 110, 1))
|
||||
>m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 112, 12))
|
||||
>Message : Symbol(Message, Decl(discriminatedUnionTypes1.ts, 61, 1))
|
||||
|
||||
switch (m.kind) {
|
||||
>m.kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 64, 5), Decl(discriminatedUnionTypes1.ts, 65, 5), Decl(discriminatedUnionTypes1.ts, 66, 5))
|
||||
>m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 112, 12))
|
||||
>kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 64, 5), Decl(discriminatedUnionTypes1.ts, 65, 5), Decl(discriminatedUnionTypes1.ts, 66, 5))
|
||||
|
||||
case "A":
|
||||
m; // { kind: "A", x: string }
|
||||
>m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 112, 12))
|
||||
|
||||
case "D":
|
||||
m; // { kind: "A", x: string } | { kind: "D" }
|
||||
>m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 112, 12))
|
||||
|
||||
break;
|
||||
default:
|
||||
m; // { kind: "B" | "C", y: number }
|
||||
>m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 112, 12))
|
||||
}
|
||||
}
|
||||
|
||||
function f7(m: Message) {
|
||||
>f7 : Symbol(f7, Decl(discriminatedUnionTypes1.ts, 122, 1))
|
||||
>m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 124, 12))
|
||||
>Message : Symbol(Message, Decl(discriminatedUnionTypes1.ts, 61, 1))
|
||||
|
||||
switch (m.kind) {
|
||||
>m.kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 64, 5), Decl(discriminatedUnionTypes1.ts, 65, 5), Decl(discriminatedUnionTypes1.ts, 66, 5))
|
||||
>m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 124, 12))
|
||||
>kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 64, 5), Decl(discriminatedUnionTypes1.ts, 65, 5), Decl(discriminatedUnionTypes1.ts, 66, 5))
|
||||
|
||||
case "A":
|
||||
case "B":
|
||||
return;
|
||||
}
|
||||
m; // { kind: "B" | "C", y: number } | { kind: "D" }
|
||||
>m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 124, 12))
|
||||
}
|
||||
|
||||
function f8(m: Message) {
|
||||
>f8 : Symbol(f8, Decl(discriminatedUnionTypes1.ts, 131, 1))
|
||||
>m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 133, 12))
|
||||
>Message : Symbol(Message, Decl(discriminatedUnionTypes1.ts, 61, 1))
|
||||
|
||||
switch (m.kind) {
|
||||
>m.kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 64, 5), Decl(discriminatedUnionTypes1.ts, 65, 5), Decl(discriminatedUnionTypes1.ts, 66, 5))
|
||||
>m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 133, 12))
|
||||
>kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 64, 5), Decl(discriminatedUnionTypes1.ts, 65, 5), Decl(discriminatedUnionTypes1.ts, 66, 5))
|
||||
|
||||
case "A":
|
||||
return;
|
||||
case "D":
|
||||
throw new Error();
|
||||
>Error : Symbol(Error, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
}
|
||||
m; // { kind: "B" | "C", y: number }
|
||||
>m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 133, 12))
|
||||
}
|
||||
@@ -1,465 +0,0 @@
|
||||
=== tests/cases/conformance/types/union/discriminatedUnionTypes1.ts ===
|
||||
interface Square {
|
||||
>Square : Square
|
||||
|
||||
kind: "square";
|
||||
>kind : "square"
|
||||
|
||||
size: number;
|
||||
>size : number
|
||||
}
|
||||
|
||||
interface Rectangle {
|
||||
>Rectangle : Rectangle
|
||||
|
||||
kind: "rectangle";
|
||||
>kind : "rectangle"
|
||||
|
||||
width: number;
|
||||
>width : number
|
||||
|
||||
height: number;
|
||||
>height : number
|
||||
}
|
||||
|
||||
interface Circle {
|
||||
>Circle : Circle
|
||||
|
||||
kind: "circle";
|
||||
>kind : "circle"
|
||||
|
||||
radius: number;
|
||||
>radius : number
|
||||
}
|
||||
|
||||
type Shape = Square | Rectangle | Circle;
|
||||
>Shape : Square | Rectangle | Circle
|
||||
>Square : Square
|
||||
>Rectangle : Rectangle
|
||||
>Circle : Circle
|
||||
|
||||
function area1(s: Shape) {
|
||||
>area1 : (s: Square | Rectangle | Circle) => number
|
||||
>s : Square | Rectangle | Circle
|
||||
>Shape : Square | Rectangle | Circle
|
||||
|
||||
if (s.kind === "square") {
|
||||
>s.kind === "square" : boolean
|
||||
>s.kind : "square" | "rectangle" | "circle"
|
||||
>s : Square | Rectangle | Circle
|
||||
>kind : "square" | "rectangle" | "circle"
|
||||
>"square" : string
|
||||
|
||||
return s.size * s.size;
|
||||
>s.size * s.size : number
|
||||
>s.size : number
|
||||
>s : Square
|
||||
>size : number
|
||||
>s.size : number
|
||||
>s : Square
|
||||
>size : number
|
||||
}
|
||||
else if (s.kind === "circle") {
|
||||
>s.kind === "circle" : boolean
|
||||
>s.kind : "rectangle" | "circle"
|
||||
>s : Rectangle | Circle
|
||||
>kind : "rectangle" | "circle"
|
||||
>"circle" : string
|
||||
|
||||
return Math.PI * s.radius * s.radius;
|
||||
>Math.PI * s.radius * s.radius : number
|
||||
>Math.PI * s.radius : number
|
||||
>Math.PI : number
|
||||
>Math : Math
|
||||
>PI : number
|
||||
>s.radius : number
|
||||
>s : Circle
|
||||
>radius : number
|
||||
>s.radius : number
|
||||
>s : Circle
|
||||
>radius : number
|
||||
}
|
||||
else if (s.kind === "rectangle") {
|
||||
>s.kind === "rectangle" : boolean
|
||||
>s.kind : "rectangle"
|
||||
>s : Rectangle
|
||||
>kind : "rectangle"
|
||||
>"rectangle" : string
|
||||
|
||||
return s.width * s.height;
|
||||
>s.width * s.height : number
|
||||
>s.width : number
|
||||
>s : Rectangle
|
||||
>width : number
|
||||
>s.height : number
|
||||
>s : Rectangle
|
||||
>height : number
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
>0 : number
|
||||
}
|
||||
}
|
||||
|
||||
function area2(s: Shape) {
|
||||
>area2 : (s: Square | Rectangle | Circle) => number
|
||||
>s : Square | Rectangle | Circle
|
||||
>Shape : Square | Rectangle | Circle
|
||||
|
||||
switch (s.kind) {
|
||||
>s.kind : "square" | "rectangle" | "circle"
|
||||
>s : Square | Rectangle | Circle
|
||||
>kind : "square" | "rectangle" | "circle"
|
||||
|
||||
case "square": return s.size * s.size;
|
||||
>"square" : string
|
||||
>s.size * s.size : number
|
||||
>s.size : number
|
||||
>s : Square
|
||||
>size : number
|
||||
>s.size : number
|
||||
>s : Square
|
||||
>size : number
|
||||
|
||||
case "rectangle": return s.width * s.height;
|
||||
>"rectangle" : string
|
||||
>s.width * s.height : number
|
||||
>s.width : number
|
||||
>s : Rectangle
|
||||
>width : number
|
||||
>s.height : number
|
||||
>s : Rectangle
|
||||
>height : number
|
||||
|
||||
case "circle": return Math.PI * s.radius * s.radius;
|
||||
>"circle" : string
|
||||
>Math.PI * s.radius * s.radius : number
|
||||
>Math.PI * s.radius : number
|
||||
>Math.PI : number
|
||||
>Math : Math
|
||||
>PI : number
|
||||
>s.radius : number
|
||||
>s : Circle
|
||||
>radius : number
|
||||
>s.radius : number
|
||||
>s : Circle
|
||||
>radius : number
|
||||
}
|
||||
}
|
||||
|
||||
function assertNever(x: never): never {
|
||||
>assertNever : (x: never) => never
|
||||
>x : never
|
||||
|
||||
throw new Error("Unexpected object: " + x);
|
||||
>new Error("Unexpected object: " + x) : Error
|
||||
>Error : ErrorConstructor
|
||||
>"Unexpected object: " + x : string
|
||||
>"Unexpected object: " : string
|
||||
>x : never
|
||||
}
|
||||
|
||||
function area3(s: Shape) {
|
||||
>area3 : (s: Square | Rectangle | Circle) => number
|
||||
>s : Square | Rectangle | Circle
|
||||
>Shape : Square | Rectangle | Circle
|
||||
|
||||
switch (s.kind) {
|
||||
>s.kind : "square" | "rectangle" | "circle"
|
||||
>s : Square | Rectangle | Circle
|
||||
>kind : "square" | "rectangle" | "circle"
|
||||
|
||||
case "square": return s.size * s.size;
|
||||
>"square" : string
|
||||
>s.size * s.size : number
|
||||
>s.size : number
|
||||
>s : Square
|
||||
>size : number
|
||||
>s.size : number
|
||||
>s : Square
|
||||
>size : number
|
||||
|
||||
case "rectangle": return s.width * s.height;
|
||||
>"rectangle" : string
|
||||
>s.width * s.height : number
|
||||
>s.width : number
|
||||
>s : Rectangle
|
||||
>width : number
|
||||
>s.height : number
|
||||
>s : Rectangle
|
||||
>height : number
|
||||
|
||||
case "circle": return Math.PI * s.radius * s.radius;
|
||||
>"circle" : string
|
||||
>Math.PI * s.radius * s.radius : number
|
||||
>Math.PI * s.radius : number
|
||||
>Math.PI : number
|
||||
>Math : Math
|
||||
>PI : number
|
||||
>s.radius : number
|
||||
>s : Circle
|
||||
>radius : number
|
||||
>s.radius : number
|
||||
>s : Circle
|
||||
>radius : number
|
||||
|
||||
default: return assertNever(s);
|
||||
>assertNever(s) : never
|
||||
>assertNever : (x: never) => never
|
||||
>s : never
|
||||
}
|
||||
}
|
||||
|
||||
function area4(s: Shape) {
|
||||
>area4 : (s: Square | Rectangle | Circle) => number
|
||||
>s : Square | Rectangle | Circle
|
||||
>Shape : Square | Rectangle | Circle
|
||||
|
||||
switch (s.kind) {
|
||||
>s.kind : "square" | "rectangle" | "circle"
|
||||
>s : Square | Rectangle | Circle
|
||||
>kind : "square" | "rectangle" | "circle"
|
||||
|
||||
case "square": return s.size * s.size;
|
||||
>"square" : string
|
||||
>s.size * s.size : number
|
||||
>s.size : number
|
||||
>s : Square
|
||||
>size : number
|
||||
>s.size : number
|
||||
>s : Square
|
||||
>size : number
|
||||
|
||||
case "rectangle": return s.width * s.height;
|
||||
>"rectangle" : string
|
||||
>s.width * s.height : number
|
||||
>s.width : number
|
||||
>s : Rectangle
|
||||
>width : number
|
||||
>s.height : number
|
||||
>s : Rectangle
|
||||
>height : number
|
||||
|
||||
case "circle": return Math.PI * s.radius * s.radius;
|
||||
>"circle" : string
|
||||
>Math.PI * s.radius * s.radius : number
|
||||
>Math.PI * s.radius : number
|
||||
>Math.PI : number
|
||||
>Math : Math
|
||||
>PI : number
|
||||
>s.radius : number
|
||||
>s : Circle
|
||||
>radius : number
|
||||
>s.radius : number
|
||||
>s : Circle
|
||||
>radius : number
|
||||
}
|
||||
return assertNever(s);
|
||||
>assertNever(s) : never
|
||||
>assertNever : (x: never) => never
|
||||
>s : never
|
||||
}
|
||||
|
||||
type Message =
|
||||
>Message : { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; }
|
||||
|
||||
{ kind: "A", x: string } |
|
||||
>kind : "A"
|
||||
>x : string
|
||||
|
||||
{ kind: "B" | "C", y: number } |
|
||||
>kind : "B" | "C"
|
||||
>y : number
|
||||
|
||||
{ kind: "D" };
|
||||
>kind : "D"
|
||||
|
||||
function f1(m: Message) {
|
||||
>f1 : (m: { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; }) => void
|
||||
>m : { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; }
|
||||
>Message : { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; }
|
||||
|
||||
if (m.kind === "A") {
|
||||
>m.kind === "A" : boolean
|
||||
>m.kind : "A" | "B" | "C" | "D"
|
||||
>m : { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; }
|
||||
>kind : "A" | "B" | "C" | "D"
|
||||
>"A" : string
|
||||
|
||||
m; // { kind: "A", x: string }
|
||||
>m : { kind: "A"; x: string; }
|
||||
}
|
||||
else if (m.kind === "D") {
|
||||
>m.kind === "D" : boolean
|
||||
>m.kind : "B" | "C" | "D"
|
||||
>m : { kind: "B" | "C"; y: number; } | { kind: "D"; }
|
||||
>kind : "B" | "C" | "D"
|
||||
>"D" : string
|
||||
|
||||
m; // { kind: "D" }
|
||||
>m : { kind: "D"; }
|
||||
}
|
||||
else {
|
||||
m; // { kind: "B" | "C", y: number }
|
||||
>m : { kind: "B" | "C"; y: number; }
|
||||
}
|
||||
}
|
||||
|
||||
function f2(m: Message) {
|
||||
>f2 : (m: { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; }) => void
|
||||
>m : { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; }
|
||||
>Message : { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; }
|
||||
|
||||
if (m.kind === "A") {
|
||||
>m.kind === "A" : boolean
|
||||
>m.kind : "A" | "B" | "C" | "D"
|
||||
>m : { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; }
|
||||
>kind : "A" | "B" | "C" | "D"
|
||||
>"A" : string
|
||||
|
||||
return;
|
||||
}
|
||||
m; // { kind: "B" | "C", y: number } | { kind: "D" }
|
||||
>m : { kind: "B" | "C"; y: number; } | { kind: "D"; }
|
||||
}
|
||||
|
||||
function f3(m: Message) {
|
||||
>f3 : (m: { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; }) => void
|
||||
>m : { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; }
|
||||
>Message : { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; }
|
||||
|
||||
if (m.kind === "X") {
|
||||
>m.kind === "X" : boolean
|
||||
>m.kind : "A" | "B" | "C" | "D"
|
||||
>m : { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; }
|
||||
>kind : "A" | "B" | "C" | "D"
|
||||
>"X" : string
|
||||
|
||||
m; // never
|
||||
>m : never
|
||||
}
|
||||
}
|
||||
|
||||
function f4(m: Message, x: "A" | "D") {
|
||||
>f4 : (m: { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; }, x: "A" | "D") => void
|
||||
>m : { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; }
|
||||
>Message : { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; }
|
||||
>x : "A" | "D"
|
||||
|
||||
if (m.kind == x) {
|
||||
>m.kind == x : boolean
|
||||
>m.kind : "A" | "B" | "C" | "D"
|
||||
>m : { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; }
|
||||
>kind : "A" | "B" | "C" | "D"
|
||||
>x : "A" | "D"
|
||||
|
||||
m; // { kind: "A", x: string } | { kind: "D" }
|
||||
>m : { kind: "A"; x: string; } | { kind: "D"; }
|
||||
}
|
||||
}
|
||||
|
||||
function f5(m: Message) {
|
||||
>f5 : (m: { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; }) => void
|
||||
>m : { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; }
|
||||
>Message : { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; }
|
||||
|
||||
switch (m.kind) {
|
||||
>m.kind : "A" | "B" | "C" | "D"
|
||||
>m : { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; }
|
||||
>kind : "A" | "B" | "C" | "D"
|
||||
|
||||
case "A":
|
||||
>"A" : string
|
||||
|
||||
m; // { kind: "A", x: string }
|
||||
>m : { kind: "A"; x: string; }
|
||||
|
||||
break;
|
||||
case "D":
|
||||
>"D" : string
|
||||
|
||||
m; // { kind: "D" }
|
||||
>m : { kind: "D"; }
|
||||
|
||||
break;
|
||||
default:
|
||||
m; // { kind: "B" | "C", y: number }
|
||||
>m : { kind: "B" | "C"; y: number; }
|
||||
}
|
||||
}
|
||||
|
||||
function f6(m: Message) {
|
||||
>f6 : (m: { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; }) => void
|
||||
>m : { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; }
|
||||
>Message : { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; }
|
||||
|
||||
switch (m.kind) {
|
||||
>m.kind : "A" | "B" | "C" | "D"
|
||||
>m : { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; }
|
||||
>kind : "A" | "B" | "C" | "D"
|
||||
|
||||
case "A":
|
||||
>"A" : string
|
||||
|
||||
m; // { kind: "A", x: string }
|
||||
>m : { kind: "A"; x: string; }
|
||||
|
||||
case "D":
|
||||
>"D" : string
|
||||
|
||||
m; // { kind: "A", x: string } | { kind: "D" }
|
||||
>m : { kind: "D"; } | { kind: "A"; x: string; }
|
||||
|
||||
break;
|
||||
default:
|
||||
m; // { kind: "B" | "C", y: number }
|
||||
>m : { kind: "B" | "C"; y: number; }
|
||||
}
|
||||
}
|
||||
|
||||
function f7(m: Message) {
|
||||
>f7 : (m: { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; }) => void
|
||||
>m : { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; }
|
||||
>Message : { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; }
|
||||
|
||||
switch (m.kind) {
|
||||
>m.kind : "A" | "B" | "C" | "D"
|
||||
>m : { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; }
|
||||
>kind : "A" | "B" | "C" | "D"
|
||||
|
||||
case "A":
|
||||
>"A" : string
|
||||
|
||||
case "B":
|
||||
>"B" : string
|
||||
|
||||
return;
|
||||
}
|
||||
m; // { kind: "B" | "C", y: number } | { kind: "D" }
|
||||
>m : { kind: "B" | "C"; y: number; } | { kind: "D"; }
|
||||
}
|
||||
|
||||
function f8(m: Message) {
|
||||
>f8 : (m: { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; }) => void
|
||||
>m : { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; }
|
||||
>Message : { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; }
|
||||
|
||||
switch (m.kind) {
|
||||
>m.kind : "A" | "B" | "C" | "D"
|
||||
>m : { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; }
|
||||
>kind : "A" | "B" | "C" | "D"
|
||||
|
||||
case "A":
|
||||
>"A" : string
|
||||
|
||||
return;
|
||||
case "D":
|
||||
>"D" : string
|
||||
|
||||
throw new Error();
|
||||
>new Error() : Error
|
||||
>Error : ErrorConstructor
|
||||
}
|
||||
m; // { kind: "B" | "C", y: number }
|
||||
>m : { kind: "B" | "C"; y: number; }
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
//// [exportToString.ts]
|
||||
const toString = 0;
|
||||
export { toString };
|
||||
|
||||
|
||||
//// [exportToString.js]
|
||||
"use strict";
|
||||
var toString = 0;
|
||||
exports.toString = toString;
|
||||
@@ -0,0 +1,7 @@
|
||||
=== tests/cases/compiler/exportToString.ts ===
|
||||
const toString = 0;
|
||||
>toString : Symbol(toString, Decl(exportToString.ts, 0, 5))
|
||||
|
||||
export { toString };
|
||||
>toString : Symbol(toString, Decl(exportToString.ts, 1, 8))
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
=== tests/cases/compiler/exportToString.ts ===
|
||||
const toString = 0;
|
||||
>toString : number
|
||||
>0 : number
|
||||
|
||||
export { toString };
|
||||
>toString : number
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
[
|
||||
"======== Resolving type reference directive 'jquery', containing file '/a/b/__inferred type names__.ts', root directory '/a/types'. ========",
|
||||
"======== Resolving type reference directive 'jquery', containing file '/__inferred type names__.ts', root directory '/a/types'. ========",
|
||||
"Resolving with primary search path '/a/types'",
|
||||
"File '/a/types/jquery/package.json' does not exist.",
|
||||
"File '/a/types/jquery/index.d.ts' exist - use it as a name resolution result.",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
[
|
||||
"======== Resolving type reference directive 'jquery', containing file '/a/b/__inferred type names__.ts', root directory '/a/types'. ========",
|
||||
"======== Resolving type reference directive 'jquery', containing file '/a/__inferred type names__.ts', root directory '/a/types'. ========",
|
||||
"Resolving with primary search path '/a/types'",
|
||||
"File '/a/types/jquery/package.json' does not exist.",
|
||||
"File '/a/types/jquery/index.d.ts' exist - use it as a name resolution result.",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
[
|
||||
"======== Resolving type reference directive 'jquery', containing file '/a/b/__inferred type names__.ts', root directory 'types'. ========",
|
||||
"======== Resolving type reference directive 'jquery', containing file '/a/__inferred type names__.ts', root directory 'types'. ========",
|
||||
"Resolving with primary search path 'types'",
|
||||
"File 'types/jquery/package.json' does not exist.",
|
||||
"File 'types/jquery/index.d.ts' exist - use it as a name resolution result.",
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
"'package.json' has 'types' field 'jquery.d.ts' that references '/types/jquery/jquery.d.ts'.",
|
||||
"File '/types/jquery/jquery.d.ts' exist - use it as a name resolution result.",
|
||||
"======== Type reference directive 'jquery' was successfully resolved to '/types/jquery/jquery.d.ts', primary: true. ========",
|
||||
"======== Resolving type reference directive 'jquery', containing file '/__inferred type names__.ts', root directory '/types'. ========",
|
||||
"======== Resolving type reference directive 'jquery', containing file 'test/__inferred type names__.ts', root directory '/types'. ========",
|
||||
"Resolving with primary search path '/types'",
|
||||
"Found 'package.json' at '/types/jquery/package.json'.",
|
||||
"'package.json' has 'types' field 'jquery.d.ts' that references '/types/jquery/jquery.d.ts'.",
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"File '/node_modules/@types/alpha/package.json' does not exist.",
|
||||
"File '/node_modules/@types/alpha/index.d.ts' exist - use it as a name resolution result.",
|
||||
"======== Type reference directive 'alpha' was successfully resolved to '/node_modules/@types/alpha/index.d.ts', primary: true. ========",
|
||||
"======== Resolving type reference directive 'alpha', containing file '/src/__inferred type names__.ts', root directory '/node_modules/@types'. ========",
|
||||
"======== Resolving type reference directive 'alpha', containing file '/__inferred type names__.ts', root directory '/node_modules/@types'. ========",
|
||||
"Resolving with primary search path '/node_modules/@types'",
|
||||
"File '/node_modules/@types/alpha/package.json' does not exist.",
|
||||
"File '/node_modules/@types/alpha/index.d.ts' exist - use it as a name resolution result.",
|
||||
|
||||
@@ -55,5 +55,5 @@ function rawr(dino: RexOrRaptor) {
|
||||
throw "Unexpected " + dino;
|
||||
>"Unexpected " + dino : string
|
||||
>"Unexpected " : string
|
||||
>dino : "t-rex"
|
||||
>dino : never
|
||||
}
|
||||
|
||||
@@ -2,9 +2,10 @@ tests/cases/conformance/jsx/file.tsx(21,16): error TS2606: Property 'x' of JSX s
|
||||
Type 'number' is not assignable to type 'string'.
|
||||
tests/cases/conformance/jsx/file.tsx(25,9): error TS2324: Property 'x' is missing in type 'Attribs1'.
|
||||
tests/cases/conformance/jsx/file.tsx(29,1): error TS2324: Property 'x' is missing in type 'Attribs1'.
|
||||
tests/cases/conformance/jsx/file.tsx(30,1): error TS2324: Property 'toString' is missing in type 'Attribs2'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/jsx/file.tsx (3 errors) ====
|
||||
==== tests/cases/conformance/jsx/file.tsx (4 errors) ====
|
||||
declare module JSX {
|
||||
interface Element { }
|
||||
interface IntrinsicElements {
|
||||
@@ -41,5 +42,7 @@ tests/cases/conformance/jsx/file.tsx(29,1): error TS2324: Property 'x' is missin
|
||||
<test1 {...{}} />; // Error, missing x
|
||||
~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2324: Property 'x' is missing in type 'Attribs1'.
|
||||
<test2 {...{}} />; // OK
|
||||
<test2 {...{}} />; // Error, missing toString
|
||||
~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2324: Property 'toString' is missing in type 'Attribs2'.
|
||||
|
||||
@@ -28,7 +28,7 @@ function make3<T extends {y: string}> (obj: T) {
|
||||
|
||||
|
||||
<test1 {...{}} />; // Error, missing x
|
||||
<test2 {...{}} />; // OK
|
||||
<test2 {...{}} />; // Error, missing toString
|
||||
|
||||
|
||||
//// [file.jsx]
|
||||
@@ -42,4 +42,4 @@ function make3(obj) {
|
||||
return <test1 {...obj}/>; // Error, missing x
|
||||
}
|
||||
<test1 {...{}}/>; // Error, missing x
|
||||
<test2 {...{}}/>; // OK
|
||||
<test2 {...{}}/>; // Error, missing toString
|
||||
|
||||
@@ -15,7 +15,7 @@ if (typeof stringOrNumber === "number") {
|
||||
>"number" : "number"
|
||||
|
||||
stringOrNumber;
|
||||
>stringOrNumber : string
|
||||
>stringOrNumber : never
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,6 @@ if (typeof stringOrNumber === "number" && typeof stringOrNumber !== "number") {
|
||||
>"number" : "number"
|
||||
|
||||
stringOrNumber;
|
||||
>stringOrNumber : string
|
||||
>stringOrNumber : never
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ function test2(a: any) {
|
||||
>"boolean" : "boolean"
|
||||
|
||||
a;
|
||||
>a : boolean
|
||||
>a : never
|
||||
}
|
||||
else {
|
||||
a;
|
||||
@@ -129,7 +129,7 @@ function test5(a: boolean | void) {
|
||||
}
|
||||
else {
|
||||
a;
|
||||
>a : void
|
||||
>a : never
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -188,7 +188,7 @@ function test7(a: boolean | void) {
|
||||
}
|
||||
else {
|
||||
a;
|
||||
>a : void
|
||||
>a : never
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -193,10 +193,10 @@ function f1() {
|
||||
>x : undefined
|
||||
|
||||
x; // string | number (guard as assertion)
|
||||
>x : string | number
|
||||
>x : never
|
||||
}
|
||||
x; // string | number | undefined
|
||||
>x : string | number | undefined
|
||||
>x : undefined
|
||||
}
|
||||
|
||||
function f2() {
|
||||
@@ -216,10 +216,10 @@ function f2() {
|
||||
>"string" : "string"
|
||||
|
||||
x; // string (guard as assertion)
|
||||
>x : string
|
||||
>x : never
|
||||
}
|
||||
x; // string | undefined
|
||||
>x : string | undefined
|
||||
>x : undefined
|
||||
}
|
||||
|
||||
function f3() {
|
||||
@@ -239,7 +239,7 @@ function f3() {
|
||||
return;
|
||||
}
|
||||
x; // string | number (guard as assertion)
|
||||
>x : string | number
|
||||
>x : never
|
||||
}
|
||||
|
||||
function f4() {
|
||||
@@ -281,7 +281,7 @@ function f5(x: string | number) {
|
||||
>"number" : "number"
|
||||
|
||||
x; // number (guard as assertion)
|
||||
>x : number
|
||||
>x : never
|
||||
}
|
||||
else {
|
||||
x; // string | number
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
tests/cases/conformance/expressions/typeGuards/typeGuardsInIfStatement.ts(22,10): error TS2354: No best common type exists among return expressions.
|
||||
tests/cases/conformance/expressions/typeGuards/typeGuardsInIfStatement.ts(31,10): error TS2354: No best common type exists among return expressions.
|
||||
tests/cases/conformance/expressions/typeGuards/typeGuardsInIfStatement.ts(49,10): error TS2354: No best common type exists among return expressions.
|
||||
tests/cases/conformance/expressions/typeGuards/typeGuardsInIfStatement.ts(139,17): error TS2339: Property 'toString' does not exist on type 'never'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/expressions/typeGuards/typeGuardsInIfStatement.ts (3 errors) ====
|
||||
==== tests/cases/conformance/expressions/typeGuards/typeGuardsInIfStatement.ts (4 errors) ====
|
||||
// In the true branch statement of an 'if' statement,
|
||||
// the type of a variable or parameter is narrowed by any type guard in the 'if' condition when true.
|
||||
// In the false branch statement of an 'if' statement,
|
||||
@@ -149,5 +150,7 @@ tests/cases/conformance/expressions/typeGuards/typeGuardsInIfStatement.ts(49,10)
|
||||
return typeof x === "number"
|
||||
? x.toString() // number
|
||||
: x.toString(); // boolean | string
|
||||
~~~~~~~~
|
||||
!!! error TS2339: Property 'toString' does not exist on type 'never'.
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
//// [index.d.ts]
|
||||
|
||||
|
||||
interface $ { x }
|
||||
|
||||
//// [app.ts]
|
||||
|
||||
@@ -9,8 +9,7 @@ interface A {
|
||||
}
|
||||
=== /types/lib/index.d.ts ===
|
||||
|
||||
|
||||
interface $ { x }
|
||||
>$ : Symbol($, Decl(index.d.ts, 0, 0))
|
||||
>x : Symbol($.x, Decl(index.d.ts, 2, 13))
|
||||
>x : Symbol($.x, Decl(index.d.ts, 1, 13))
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@ interface A {
|
||||
}
|
||||
=== /types/lib/index.d.ts ===
|
||||
|
||||
|
||||
interface $ { x }
|
||||
>$ : $
|
||||
>x : any
|
||||
|
||||
@@ -39,6 +39,7 @@ var t = p.x;
|
||||
=== tests/cases/conformance/externalModules/node_modules/math2d/index.d.ts ===
|
||||
|
||||
export as namespace Math2d;
|
||||
>Math2d : Symbol(Math2d, Decl(index.d.ts, 0, 0))
|
||||
|
||||
export interface Point {
|
||||
>Point : Symbol(Point, Decl(index.d.ts, 1, 27))
|
||||
|
||||
@@ -48,7 +48,7 @@ var t = p.x;
|
||||
=== tests/cases/conformance/externalModules/node_modules/math2d/index.d.ts ===
|
||||
|
||||
export as namespace Math2d;
|
||||
>Math2d : any
|
||||
>Math2d : typeof Math2d
|
||||
|
||||
export interface Point {
|
||||
>Point : Point
|
||||
|
||||
@@ -37,6 +37,7 @@ var t = p.x;
|
||||
=== tests/cases/conformance/externalModules/node_modules/math2d/index.d.ts ===
|
||||
|
||||
export as namespace Math2d;
|
||||
>Math2d : Symbol(Math2d, Decl(index.d.ts, 0, 0))
|
||||
|
||||
export interface Point {
|
||||
>Point : Symbol(Point, Decl(index.d.ts, 1, 27))
|
||||
|
||||
@@ -46,7 +46,7 @@ var t = p.x;
|
||||
=== tests/cases/conformance/externalModules/node_modules/math2d/index.d.ts ===
|
||||
|
||||
export as namespace Math2d;
|
||||
>Math2d : any
|
||||
>Math2d : typeof Math2d
|
||||
|
||||
export interface Point {
|
||||
>Point : Point
|
||||
|
||||
@@ -39,6 +39,7 @@ var t = p.x;
|
||||
=== tests/cases/conformance/externalModules/node_modules/math2d/index.d.ts ===
|
||||
|
||||
export as namespace Math2d;
|
||||
>Math2d : Symbol(Math2d, Decl(index.d.ts, 0, 0))
|
||||
|
||||
export = M2D;
|
||||
>M2D : Symbol(M2D, Decl(index.d.ts, 3, 13))
|
||||
|
||||
@@ -48,7 +48,7 @@ var t = p.x;
|
||||
=== tests/cases/conformance/externalModules/node_modules/math2d/index.d.ts ===
|
||||
|
||||
export as namespace Math2d;
|
||||
>Math2d : any
|
||||
>Math2d : typeof Math2d
|
||||
|
||||
export = M2D;
|
||||
>M2D : typeof M2D
|
||||
|
||||
@@ -37,6 +37,7 @@ var t = p.x;
|
||||
=== tests/cases/conformance/externalModules/node_modules/math2d/index.d.ts ===
|
||||
|
||||
export as namespace Math2d;
|
||||
>Math2d : Symbol(Math2d, Decl(index.d.ts, 0, 0))
|
||||
|
||||
export = M2D;
|
||||
>M2D : Symbol(M2D, Decl(index.d.ts, 3, 13))
|
||||
|
||||
@@ -46,7 +46,7 @@ var t = p.x;
|
||||
=== tests/cases/conformance/externalModules/node_modules/math2d/index.d.ts ===
|
||||
|
||||
export as namespace Math2d;
|
||||
>Math2d : any
|
||||
>Math2d : typeof Math2d
|
||||
|
||||
export = M2D;
|
||||
>M2D : typeof M2D
|
||||
|
||||
@@ -30,4 +30,5 @@ export interface Thing { n: typeof x }
|
||||
>x : Symbol(x, Decl(foo.d.ts, 1, 10))
|
||||
|
||||
export as namespace Foo;
|
||||
>Foo : Symbol(Foo, Decl(foo.d.ts, 3, 38))
|
||||
|
||||
|
||||
@@ -31,5 +31,5 @@ export interface Thing { n: typeof x }
|
||||
>x : number
|
||||
|
||||
export as namespace Foo;
|
||||
>Foo : any
|
||||
>Foo : typeof Foo
|
||||
|
||||
|
||||
@@ -32,4 +32,5 @@ export interface Thing { n: typeof x }
|
||||
>x : Symbol(x, Decl(foo.d.ts, 1, 10))
|
||||
|
||||
export as namespace Foo;
|
||||
>Foo : Symbol(Foo, Decl(foo.d.ts, 3, 38))
|
||||
|
||||
|
||||
@@ -33,5 +33,5 @@ export interface Thing { n: typeof x }
|
||||
>x : number
|
||||
|
||||
export as namespace Foo;
|
||||
>Foo : any
|
||||
>Foo : typeof Foo
|
||||
|
||||
|
||||
@@ -32,4 +32,5 @@ export interface Thing { n: typeof x }
|
||||
>x : Symbol(x, Decl(foo.d.ts, 1, 10))
|
||||
|
||||
export as namespace Foo;
|
||||
>Foo : Symbol(Foo, Decl(foo.d.ts, 3, 38))
|
||||
|
||||
|
||||
@@ -33,5 +33,5 @@ export interface Thing { n: typeof x }
|
||||
>x : number
|
||||
|
||||
export as namespace Foo;
|
||||
>Foo : any
|
||||
>Foo : typeof Foo
|
||||
|
||||
|
||||
@@ -18,4 +18,5 @@ export = Thing;
|
||||
>Thing : Symbol(Thing, Decl(foo.d.ts, 0, 0))
|
||||
|
||||
export as namespace Foo;
|
||||
>Foo : Symbol(Foo, Decl(foo.d.ts, 4, 15))
|
||||
|
||||
|
||||
@@ -19,5 +19,5 @@ export = Thing;
|
||||
>Thing : typeof Thing
|
||||
|
||||
export as namespace Foo;
|
||||
>Foo : any
|
||||
>Foo : typeof Thing
|
||||
|
||||
|
||||
@@ -13,4 +13,5 @@ export = Thing;
|
||||
>Thing : Symbol(Thing, Decl(foo.d.ts, 0, 0))
|
||||
|
||||
export as namespace Foo;
|
||||
>Foo : Symbol(Foo, Decl(foo.d.ts, 2, 15))
|
||||
|
||||
|
||||
@@ -14,5 +14,5 @@ export = Thing;
|
||||
>Thing : () => number
|
||||
|
||||
export as namespace Foo;
|
||||
>Foo : any
|
||||
>Foo : () => number
|
||||
|
||||
|
||||
@@ -22,4 +22,5 @@ export = Thing;
|
||||
>Thing : Symbol(Thing, Decl(foo.d.ts, 0, 0))
|
||||
|
||||
export as namespace Foo;
|
||||
>Foo : Symbol(Foo, Decl(foo.d.ts, 4, 15))
|
||||
|
||||
|
||||
@@ -23,5 +23,5 @@ export = Thing;
|
||||
>Thing : Thing
|
||||
|
||||
export as namespace Foo;
|
||||
>Foo : any
|
||||
>Foo : typeof Thing
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
// @allowSyntheticDefaultImports: true
|
||||
// @module: commonjs
|
||||
// @Filename: b.d.ts
|
||||
export function foo();
|
||||
|
||||
export function bar();
|
||||
|
||||
// @Filename: a.ts
|
||||
import Foo = require("./b");
|
||||
Foo.default.bar();
|
||||
Foo.default.default.foo();
|
||||
@@ -0,0 +1,10 @@
|
||||
// @module: system
|
||||
// @Filename: b.d.ts
|
||||
export function foo();
|
||||
|
||||
export function bar();
|
||||
|
||||
// @Filename: a.ts
|
||||
import { default as Foo } from "./b";
|
||||
Foo.bar();
|
||||
Foo.foo();
|
||||
@@ -0,0 +1,11 @@
|
||||
// @allowSyntheticDefaultImports: false
|
||||
// @module: system
|
||||
// @Filename: b.d.ts
|
||||
export function foo();
|
||||
|
||||
export function bar();
|
||||
|
||||
// @Filename: a.ts
|
||||
import { default as Foo } from "./b";
|
||||
Foo.bar();
|
||||
Foo.foo();
|
||||
@@ -0,0 +1,11 @@
|
||||
// @allowSyntheticDefaultImports: true
|
||||
// @module: commonjs
|
||||
// @Filename: b.d.ts
|
||||
export function foo();
|
||||
|
||||
export function bar();
|
||||
|
||||
// @Filename: a.ts
|
||||
import { default as Foo } from "./b";
|
||||
Foo.bar();
|
||||
Foo.foo();
|
||||
@@ -0,0 +1,2 @@
|
||||
const toString = 0;
|
||||
export { toString };
|
||||
@@ -2,7 +2,7 @@
|
||||
// @traceResolution: true
|
||||
// @declaration: true
|
||||
// @typeRoots: /types
|
||||
|
||||
// @currentDirectory: /
|
||||
|
||||
// @filename: /types/lib/index.d.ts
|
||||
interface $ { x }
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// @declaration: true
|
||||
// @typeRoots: /types
|
||||
// @traceResolution: true
|
||||
// @currentDirectory: /
|
||||
|
||||
// @filename: /ref.d.ts
|
||||
export interface $ { x }
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
// @types: lib
|
||||
// @out: output.js
|
||||
// @module: amd
|
||||
// @currentDirectory: /
|
||||
|
||||
// @filename: /types/lib/index.d.ts
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
// @traceResolution: true
|
||||
// @out: output.js
|
||||
// @module: amd
|
||||
// @currentDirectory: /
|
||||
|
||||
// @filename: /types/lib/index.d.ts
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// @declaration: true
|
||||
// @typeRoots: /types
|
||||
// @traceResolution: true
|
||||
// @currentDirectory: /
|
||||
|
||||
// @filename: /ref.d.ts
|
||||
export interface $ { x }
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
// @declaration: true
|
||||
// @typeRoots: /types
|
||||
// @types: lib
|
||||
// @currentDirectory: /
|
||||
|
||||
// @filename: /types/lib/index.d.ts
|
||||
interface $ { x }
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// @declaration: true
|
||||
// @typeRoots: /types
|
||||
// @traceResolution: true
|
||||
// @currentDirectory: /
|
||||
|
||||
// $ comes from d.ts file - no need to add type reference directive
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// @traceResolution: true
|
||||
// @declaration: true
|
||||
// @typeRoots: /types
|
||||
// @currentDirectory: /
|
||||
|
||||
// $ comes from d.ts file - no need to add type reference directive
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// @traceResolution: true
|
||||
// @declaration: true
|
||||
// @typeRoots: /types
|
||||
// @currentDirectory: /
|
||||
|
||||
// @filename: /ref.d.ts
|
||||
export interface $ { x }
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// @traceResolution: true
|
||||
// @declaration: true
|
||||
// @typeRoots: /types
|
||||
// @currentDirectory: /
|
||||
|
||||
// $ comes from type declaration file - type reference directive should be added
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// @traceResolution: true
|
||||
// @declaration: true
|
||||
// @typeRoots: /types
|
||||
// @currentDirectory: /
|
||||
|
||||
// local value shadows global - no need to add type reference directive
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
// @typeRoots: /types
|
||||
// @traceResolution: true
|
||||
// @types: lib
|
||||
// @currentDirectory: /
|
||||
|
||||
// @filename: /types/lib/index.d.ts
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// @declaration: true
|
||||
// @typeRoots: /types
|
||||
// @traceResolution: true
|
||||
// @currentDirectory: /
|
||||
|
||||
// @filename: /types/lib/index.d.ts
|
||||
|
||||
|
||||
@@ -29,4 +29,4 @@ function make3<T extends {y: string}> (obj: T) {
|
||||
|
||||
|
||||
<test1 {...{}} />; // Error, missing x
|
||||
<test2 {...{}} />; // OK
|
||||
<test2 {...{}} />; // Error, missing toString
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// @noImplicitReferences: true
|
||||
// @traceResolution: true
|
||||
// @currentDirectory: /
|
||||
|
||||
// load type declarations from types section of tsconfig
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// @traceResolution: true
|
||||
// @noImplicitReferences: true
|
||||
// @currentDirectory: /
|
||||
|
||||
// @filename: /tsconfig.json
|
||||
{ "files": "a.ts" }
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
// @Filename: 0.d.ts
|
||||
//// export function doThing(): string;
|
||||
//// export function doTheOtherThing(): void;
|
||||
|
||||
//// export as namespace [|myLib|];
|
||||
|
||||
// @Filename: 1.ts
|
||||
//// /// <reference path="0.d.ts" />
|
||||
//// [|myLib|].doThing();
|
||||
|
||||
verify.rangesReferenceEachOther();
|
||||
@@ -0,0 +1,17 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
// @Filename: 0.d.ts
|
||||
//// export function doThing(): string;
|
||||
//// export function doTheOtherThing(): void;
|
||||
|
||||
//// export as namespace /*0*/myLib;
|
||||
|
||||
// @Filename: 1.ts
|
||||
//// /// <reference path="0.d.ts" />
|
||||
//// /*1*/myLib.doThing();
|
||||
|
||||
goTo.marker("0");
|
||||
verify.quickInfoIs("export namespace myLib");
|
||||
|
||||
goTo.marker("1");
|
||||
verify.quickInfoIs("export namespace myLib");
|
||||
@@ -4,8 +4,8 @@
|
||||
////import [|M|] = SomeModule;
|
||||
////import C = [|M|].SomeClass;
|
||||
|
||||
let ranges = test.ranges()
|
||||
for (let range of ranges) {
|
||||
goTo.position(range.start);
|
||||
verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false);
|
||||
let ranges = test.ranges()
|
||||
for (let range of ranges) {
|
||||
goTo.position(range.start);
|
||||
verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false);
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
// @Filename: 0.d.ts
|
||||
//// export function doThing(): string;
|
||||
//// export function doTheOtherThing(): void;
|
||||
|
||||
//// export as namespace [|myLib|];
|
||||
|
||||
// @Filename: 1.ts
|
||||
//// /// <reference path="0.d.ts" />
|
||||
//// [|myLib|].doThing();
|
||||
|
||||
const ranges = test.ranges()
|
||||
for (const range of ranges) {
|
||||
goTo.position(range.start);
|
||||
verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
// @Filename: 0.d.ts
|
||||
//// export function doThing(): string;
|
||||
//// export function doTheOtherThing(): void;
|
||||
|
||||
//// export as namespace /**/[|myLib|];
|
||||
|
||||
// @Filename: 1.ts
|
||||
//// /// <reference path="0.d.ts" />
|
||||
//// myLib.doThing();
|
||||
|
||||
goTo.marker();
|
||||
verify.renameInfoSucceeded("myLib");
|
||||
Reference in New Issue
Block a user