express-typescript-starter | 👍 Build APIs You Wo n't Hate In Node Js | REST library
kandi X-RAY | express-typescript-starter Summary
kandi X-RAY | express-typescript-starter Summary
Project is a faster way to building a Node.js RESTful API in TypeScript. Start use now and just focus on your business and not spending hours in project configuration.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of express-typescript-starter
express-typescript-starter Key Features
express-typescript-starter Examples and Code Snippets
Community Discussions
Trending Discussions on express-typescript-starter
QUESTION
When I build my application I get. error TS2339: Property 'split' does not exist on type 'string | string[]'.
Property 'split' does not exist on type 'string[]'.
How can a split not exist on a string or string[]. It seems weird it sees it as a string array because it throws the error on a req.headers.authorization.split(" ")[1]. So this is basically: "Bearer (the token) so this seems to me a string that is getting split.
I'm using typescript version 2.3.
I tried changing the target in tsconfig to es2017.
I tried changing the lib to es6 and es7
All didn't work.
What rookie mistake did I make
This is my tsconfig.json
...ANSWER
Answered 2017-Dec-14 at 12:49The type you are trying to invoke split
on is string|string[]
, which means that value may be either a string
or a string[]
, in order for TypeScript to be happy, BOTH types must have a split
method. If you are confident that it will always be a string, either update the definition (if possible) or cast to a string
before calling split
:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install express-typescript-starter
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page