mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-17 21:06:50 -05:00
Fixed default import from export equals
(cherry picked from commit c4a10cfcdd)
This commit is contained in:
27
tests/baselines/reference/exportEqualsDefaultProperty.js
Normal file
27
tests/baselines/reference/exportEqualsDefaultProperty.js
Normal file
@@ -0,0 +1,27 @@
|
||||
//// [tests/cases/compiler/exportEqualsDefaultProperty.ts] ////
|
||||
|
||||
//// [exp.ts]
|
||||
|
||||
var x = {
|
||||
"greeting": "hello, world",
|
||||
"default": 42
|
||||
};
|
||||
|
||||
export = x
|
||||
|
||||
//// [imp.ts]
|
||||
import foo from "./exp";
|
||||
foo.toExponential(2);
|
||||
|
||||
|
||||
//// [exp.js]
|
||||
"use strict";
|
||||
var x = {
|
||||
"greeting": "hello, world",
|
||||
"default": 42
|
||||
};
|
||||
module.exports = x;
|
||||
//// [imp.js]
|
||||
"use strict";
|
||||
var exp_1 = require("./exp");
|
||||
exp_1["default"].toExponential(2);
|
||||
@@ -0,0 +1,21 @@
|
||||
=== tests/cases/compiler/exp.ts ===
|
||||
|
||||
var x = {
|
||||
>x : Symbol(x, Decl(exp.ts, 1, 3))
|
||||
|
||||
"greeting": "hello, world",
|
||||
"default": 42
|
||||
};
|
||||
|
||||
export = x
|
||||
>x : Symbol(x, Decl(exp.ts, 1, 3))
|
||||
|
||||
=== tests/cases/compiler/imp.ts ===
|
||||
import foo from "./exp";
|
||||
>foo : Symbol(foo, Decl(imp.ts, 0, 6))
|
||||
|
||||
foo.toExponential(2);
|
||||
>foo.toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, --, --))
|
||||
>foo : Symbol(foo, Decl(imp.ts, 0, 6))
|
||||
>toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, --, --))
|
||||
|
||||
28
tests/baselines/reference/exportEqualsDefaultProperty.types
Normal file
28
tests/baselines/reference/exportEqualsDefaultProperty.types
Normal file
@@ -0,0 +1,28 @@
|
||||
=== tests/cases/compiler/exp.ts ===
|
||||
|
||||
var x = {
|
||||
>x : { "greeting": string; "default": number; }
|
||||
>{ "greeting": "hello, world", "default": 42} : { "greeting": string; "default": number; }
|
||||
|
||||
"greeting": "hello, world",
|
||||
>"hello, world" : string
|
||||
|
||||
"default": 42
|
||||
>42 : number
|
||||
|
||||
};
|
||||
|
||||
export = x
|
||||
>x : { "greeting": string; "default": number; }
|
||||
|
||||
=== tests/cases/compiler/imp.ts ===
|
||||
import foo from "./exp";
|
||||
>foo : number
|
||||
|
||||
foo.toExponential(2);
|
||||
>foo.toExponential(2) : string
|
||||
>foo.toExponential : (fractionDigits?: number) => string
|
||||
>foo : number
|
||||
>toExponential : (fractionDigits?: number) => string
|
||||
>2 : number
|
||||
|
||||
12
tests/cases/compiler/exportEqualsDefaultProperty.ts
Normal file
12
tests/cases/compiler/exportEqualsDefaultProperty.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
|
||||
// @Filename: exp.ts
|
||||
var x = {
|
||||
"greeting": "hello, world",
|
||||
"default": 42
|
||||
};
|
||||
|
||||
export = x
|
||||
|
||||
// @Filename: imp.ts
|
||||
import foo from "./exp";
|
||||
foo.toExponential(2);
|
||||
@@ -5,9 +5,28 @@
|
||||
//// function foo() { return {a: "hello, world"}; }
|
||||
//// module.exports = foo();
|
||||
|
||||
// @Filename: mod2.js
|
||||
//// var x = {name: 'test'};
|
||||
//// (function createExport(obj){
|
||||
//// module.exports = {
|
||||
//// "default": x,
|
||||
//// "sausages": {eggs: 2}
|
||||
//// };
|
||||
//// })();
|
||||
|
||||
// @Filename: app.js
|
||||
//// import {a} from "./mod"
|
||||
//// import def, {sausages} from "./mod2"
|
||||
//// a./**/
|
||||
|
||||
goTo.marker();
|
||||
verify.completionListContains('toString');
|
||||
|
||||
edit.backspace(2);
|
||||
edit.insert("def.");
|
||||
verify.completionListContains("name");
|
||||
|
||||
edit.insert("name;\nsausages.");
|
||||
verify.completionListContains("eggs");
|
||||
edit.insert("eggs;");
|
||||
verify.numberOfErrorsInCurrentFile(0);
|
||||
|
||||
Reference in New Issue
Block a user