Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • C create-react-app
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1,547
    • Issues 1,547
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 417
    • Merge requests 417
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Meta
  • create-react-app
  • Issues
  • #7167
Closed
Open
Issue created Jun 04, 2019 by Administrator@rootContributor

Typescript: ambient declaration file that declares a namespace results in build errors

Created by: andyhopp

Is this a bug report?

Yes

Did you try recovering your dependencies?

Yes $ npm --version 6.9.0

Which terms did you search for in User Guide?

Typescript Declaration @types

Environment

Environment Info:

System: OS: macOS High Sierra 10.13.6 CPU: x64 Intel(R) Core(TM) i5-5257U CPU @ 2.70GHz Binaries: Node: 10.15.3 - /usr/local/bin/node npm: 6.9.0 - /usr/local/bin/npm Browsers: Chrome: 74.0.3729.169 Firefox: 60.6.2 Safari: 12.1.1 npmPackages: react: ^16.8.6 => 16.8.6 react-dom: ^16.8.6 => 16.8.6 react-scripts: 3.0.1 => 3.0.1 npmGlobalPackages: create-react-app: 2.1.8

Steps to Reproduce

  1. create-react-app my-app --typescript
  2. cd my-app
  3. npm i --save-dev @types/amazon-connect-streams
  4. Create a file named src/connect-service.ts:
export class Connect {
    constructor() {
    }

    public initialize(ccpElement: HTMLElement, options: connect.InitCCPOptions) {
        connect.core.initCCP(ccpElement, options);
        console.log('CCP Initialized!');
    }
}
  1. npm i -g typescript # To demonstrate the Typescript compiler
  2. tsc --build tsconfig.json # Note no errors
  3. npm run-script build

Expected Behavior

I expected the CRA build to behave similarly to the native TS compiler.

Actual Behavior

=============
Failed to compile.

./src/connect-service.ts
  Line 6:  'connect' is not defined  no-undef

Search for the keywords to learn more about each error.


npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! connect-react-example@0.1.0 build: `react-scripts build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the connect-react-example@0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

Reproducible Demo

The steps above only require an NPM install of a types file and a single file to be created.

Assignee
Assign to
Time tracking