Skip to content

type export issue #47374

@waitingsong

Description

@waitingsong

Issue Type: Bug

tsconfig.json

{
  "compilerOptions": {
    "alwaysStrict": true,           /* Parse in strict mode and emit "use strict" for each source file. */
    "declaration": true,            /* Generates corresponding '.d.ts' file. */
    "module": "commonjs",           /* 'commonjs', 'amd', 'system', 'umd' or 'es2015'. */
    "strict": true,                 /* Enable all strict type-checking options. */
    "target": "ES2017",              /* 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */
    "types" : ["node"]
  }
}

package.json

{
  "name": "",
  "version": "1.0.0",
  "description": "",
  "private": true,
  "scripts": {},
  "dependencies": {},
  "devDependencies": {
    "@types/node": "^7.0.12",
    "tslib": "^1.9.0",
    "typescript": "^2.8.1"
  },
  "engines": {
    "node": ">=8.9.0"
  }
} 

config/config.default.ts

export interface Config {
  keys: string
  news: {
    pageSize: number;
  };
}

export type PowerPartial<T> = {
  [U in keyof T]?: T[U] extends {}
  ? PowerPartial<T[U]>
  : T[U]
}

// for config.{env}.ts
export type DefaultConfig = PowerPartial<Config>;

config.local.ts

import { DefaultConfig } from './config.default';

export default () => {
  const config: DefaultConfig = {};

  config.sourceUrl = 'foo'
  config.news = {
    pageSize: 20,
  };

  return config;
}; 

got error:

config/config.local.ts(3,1): error TS4082: Default export of the module has or is using private name 'PowerPartial'.
config/config.local.ts(6,10): error TS2339: Property 'sourceUrl' does not exist on type 'PowerPartial<Config>'.
11:06:36 - Compilation complete. Watching for file changes.

if change to `"declaration": false,``` , then issue gone.
any suggestion ?

VS Code version: Code 1.21.1 (79b44aa, 2018-03-14T14:46:47.128Z)
OS version: Windows_NT x64 6.1.7601

System Info
Item Value
CPUs Intel(R) Core(TM) i5 CPU 760 @ 2.80GHz (4 x 2809)
Memory (System) 15.97GB (4.32GB free)
Process Argv C:\Program Files\Microsoft VS Code\Code.exe E:\project\tt\ts\config\config.local.ts
Screen Reader no
VM 67%
Extensions: none Reproduces without extensions

Metadata

Metadata

Assignees

Labels

typescriptTypescript support issuesupstreamIssue identified as 'upstream' component related (exists outside of VS Code)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions